removeclass不是函数错误

时间:2014-03-25 13:40:56

标签: jquery html

当我尝试使用eq()删除类时,它无效并在控制台TypeError中给出错误:$(...).removeclass is not a function

$("table tr:eq(9)").removeclass('mandatory');**strong text**

html代码:

 <html> <head> <script type="text/javascript"
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
 <script type="text/javascript" src="anim_navbar_webmuch.js"></script>
 </script> <script type="text/javascript" src="table.js"> </script>
 <style type="text/css"> .mandatory { background-color:red; color:blue;
 } </style> </head> <body>

 <table> <tr><td><h2 style="
 background-color:blue;">table</h2></td></tr>
 <tr><td><p>hdshjdshdskhjkds</p></td></tr> <tr><td>Yes<input
 name="yescheck" id="one" type="checkbox" value="yes" > </td></tr>
 <tr><td>No<input type="checkbox" value="no" name="nocheck"></td></tr>
 <tr><td><p>Hi to alll</p></td></tr> <tr><td>Yes<input name="yesnext"
 type="checkbox" value="yes"></td></tr> <tr><td>No<input name="nonext"
 type="checkbox" value="no"></td></tr> <tr><td><p>Hi to
 alll</p></td></tr> <tr><td>hi<input type="textbox"></td></tr> <tr><td
 class="mandatory">hi1<input type="textbox"></td></tr>
 <tr><td>hi2<input type="textbox"></td></tr> <tr><td>hi3<input
 type="textbox"></td></tr> <tr><td>hi4<input type="textbox"></td></tr>
 <tr><td>hi5<input type="textbox"></td></tr> <tr><td>hi6<input
 type="textbox"></td></tr> <tr><td>Hi7 <select>   <option
 value="volvo">Volvo</option>   <option value="saab">Saab</option>  
 <option value="mercedes">Mercedes</option>   <option
 value="audi">Audi</option> </select> </td></tr> </table>
 <button>submit</button> </body> </html>

JS

    $(document).ready(function(){
    var checkyes1 = $('input:checkbox[name=yescheck]');


    checkyes1.click(function(){
         //var checkConf =$checkyes1.attr('checked',true);
         if(this.checked)
         {
             checkno1.attr('disabled',true);
             //alert("jj");
             $("table tr").eq(1).hide();
             $("table tr").slice(5).hide();
             $("table tr").slice(8,14).show();
             $("table tr:eq(9)").removeclass('mandatory');
             //$("body p").hide();
             console.log($("table tr:eq(9)").length);

             }
             else{
                 checkno1.attr('disabled',false);
                 $("table tr").slice(8,14).hide();
                 }

        });
    //$checkyes1.prop("checked",true);
        });

1 个答案:

答案 0 :(得分:10)

应该是像骆驼一样,

.removeClass('mandatory');
-------^

请阅读here以了解有关.removeClass()

的更多信息