简体   繁体   中英

How remove specific div code from html using java or jquery

I want to remove the below 2 codes from my html on page load using java or jquery...

Important: I only want to remove these 2 lines - don't want to remove the content associated with it.

 <div id="left" style="width: 676px;"> 

 <table id="mainpage" style="width: 100%; text-align: center;" cellspacing="0"> 

This is the link to my main code which has the above strings as well, view code on this link

You can use:

$("#mainpage, #left").remove();

Or

$("#mainpage").attr('style', '');
$("#left").attr('style', '');

Or

var htmlInMainPage = $("#mainpage").html().remove();
$('table').append(htmlInMainPage);

Or explain better your question.

If you know elements class or ID, you can use

display:none

If you know element order within the parent, for example third .btn

.btn-nth-of-type(3) {display:none}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM