class类属性的操作

   <style type="text/css">
        .apple{color:red; background-color:lightblue;}
        .pear{width:300px; height:50px;}
        </style>
 function f3(){
    //toggleClass 设置class属性
    //判断节点是否有该class属性
    //如果有,则把它删除
    //如果没有,就给设置上
    $("input:first").toggleClass("apple");
}
function f1(){
    $("input:eq(0)").addClass("apple pear");
}
function f2(){
    $("input:first").removeClass("apple");
}

 

你可能感兴趣的:(class类属性的操作)