开发者

js function to jquery

开发者 https://www.devze.com 2023-02-07 12:16 出处:网络
i have a function like this 开发者_如何转开发in js function rmStyle(parent){ var rmStyle=document.getElementById(parent).getElementsByTagName(\"a\");

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

精彩评论

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