js function to jquery
i have a function like this 开发者_如何转开发in js
function rmStyle(parent){
var rmStyle=document.getElementById(parent).getElementsByTagName("a");
for (i=0;i<rmStyle.length;i++){rmStyle[i].className="";}}
i'd like to shorten the function, since i'm using jQuery... so, what should i write in jQuery?
$('#' + parent).find('a').removeClass();
The .removeClass() method will remove all classes on a selected item if no class name is passed.
function rmStyle(parent) {
$('#' + parent).find('a').attr('class','');
}
This will get the element with the parent
id, find all a
descendants, and set their class
attribute to ''
.
精彩评论