removing div tag from html

Posted by Venkatesh under ASP.NET on 9/14/2016 | Points: 10 | Views : 1001 | Status : [Member] | Replies : 3
Hello Everyone,

i have an html content. in that html i want to remove the div tags which is having style="display:none" property for these div doesn't have any id's.

Thanks,
Venkatesh.P




Responses

Posted by: Sheonarayan on: 9/14/2016 [Administrator] HonoraryPlatinum | Points: 25

Up
1
Down
Use attribute selector to find all the divs having style="display:none" and call .remove() function.

So your code should look like this

  <script>
$(function () {
$("div[style='display:none']").remove();
});
</script>


Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 9/14/2016 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying, but i need this into server side.

Thanks,
Venkatesh.P

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 9/14/2016 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
You may use regular expression (you will have to build that regular expression) and find those elements and remove it. Otherwise bring it down to client side and on page load, remove the element using javascript and the above code will work perfectly.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response