Jquery addClass实际上删除了我代码中的类

Jquery addClass实际上删除了我代码中的类,jquery,Jquery,addClass(“x”)实际上删除了我代码中的类“x”。使用调试器检查时,removeClass(“x”)不会被调用 这是我的密码 $('.list-item > li:first-child').addClass('hide-lead'); 谁来帮忙 您确定代码中没有任何额外的jquery脚本吗 这里有一个代码示例,它可以工作: 我看不出任何错误。您确定代码中没有任何额外的jquery脚本吗 <html> <head> <script src="htt

addClass(“x”)
实际上删除了我代码中的类“x”。使用调试器检查时,
removeClass(“x”)
不会被调用

这是我的密码

$('.list-item > li:first-child').addClass('hide-lead');

谁来帮忙

您确定代码中没有任何额外的
jquery
脚本吗

这里有一个代码示例,它可以工作:


我看不出任何错误。

您确定代码中没有任何额外的
jquery
脚本吗

<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<style>
    .hide-lead {
    color:red;
    }

</style>
<script>
    $(document).ready(function () {

        $('#add').click(function () {
            $('.list-item > li:first-child').addClass('hide-lead');
        });

        $('#remove').click(function () {
            $('.list-item > li:first-child').removeClass('hide-lead');
        });

    });
</script>
</head>
<body>
    <input type="button" value="Add Class" id="add" />
        <input type="button" value="Remove Class" id="remove" />
  <ul class="list-item">
      <li>hello1</li>
        <li>hello2</li> 
       <li>hello3</li>


  </ul>
</body>
</html>
这里有一个代码示例,它可以工作:

我看不出有什么问题。


<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<style>
    .hide-lead {
    color:red;
    }

</style>
<script>
    $(document).ready(function () {

        $('#add').click(function () {
            $('.list-item > li:first-child').addClass('hide-lead');
        });

        $('#remove').click(function () {
            $('.list-item > li:first-child').removeClass('hide-lead');
        });

    });
</script>
</head>
<body>
    <input type="button" value="Add Class" id="add" />
        <input type="button" value="Remove Class" id="remove" />
  <ul class="list-item">
      <li>hello1</li>
        <li>hello2</li> 
       <li>hello3</li>


  </ul>
</body>
</html>
.隐藏线索{ 颜色:红色; } $(文档).ready(函数(){ $('#添加')。单击(函数(){ $('.list item>li:first child').addClass('hide-lead'); }); $(“#删除”)。单击(函数(){ $('.list item>li:first child').removeClass('hide-lead'); }); });
  • 你好
  • 你好
  • 你好

.隐藏线索{
颜色:红色;
}
$(文档).ready(函数(){
$('#添加')。单击(函数(){
$('.list item>li:first child').addClass('hide-lead');
});
$(“#删除”)。单击(函数(){
$('.list item>li:first child').removeClass('hide-lead');
});
});
  • 你好
  • 你好
  • 你好

正如你们所说,我在代码中错误地调用了removeClass。经过长时间的斗争,我发现removeClass隐藏在我的长jquery中

正如你们所说,我在代码中错误地调用了removeClass。经过长时间的斗争,我发现removeClass隐藏在我的长jquery中

请显示工作代码以帮助更好地理解。是的,需要更多代码!有人给了你一个jquery库,它将addClass功能与removeClass切换:)@madalinivascufunny@Seabizkit可能发生:))请显示工作代码以帮助更好地理解。是的,需要更多代码!有人给了你一个jquery库,它将addClass功能与removeClass切换:)@madalinivascufunny@Seabizkit可能发生:))