开发者

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 non开发者_如何学编程e. How can this be done using jquery code. Some example code would be really appreciated

Please Help. Thank You


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">.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜