开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜