Skip to content Skip to sidebar Skip to footer

Setting Style Attribute To None For Every Table Tr And Td Elements Inside A Div Using Jquery

I have a div with id testdiv. Inside the div i have a table with no id or class . I would like to set the style attribute of all table tr and td elements inside the div to none. H

Solution 1:

You can use .removeAttr(), like this:

$("#testdiv").find("table, tr, td").removeAttr("style");

Note though this just removes inline styles, whatever's defined in your stylesheets will still apply.

From a more general standpoint, an ID is never needed to select an element, you can just use an element selector like I have in the .find() call above, so for example this code looks for all <table>, <tr>, and <td> elements that are descendants of that <div id="testdiv">.

Post a Comment for "Setting Style Attribute To None For Every Table Tr And Td Elements Inside A Div Using Jquery"