Jquery改变类

标签 jquery jquery-ui

我正在尝试更改位于 h3 内的跨度的类,但我无法这样做。这是我想要完成的任务的链接:http://jsfiddle.net/WPxG4/9/

代码:

jQuery(document).ready(function() {
    $('h3').click(function() {
        $(this).next('ul').toggle();
        $(this).next('span').toggleClass('special1', 'special');
        return false;
    }).next().hide();
});

HTML:

<h3><span class="special"></span><a href="#">Heading 1</a></h3>
<ul>
    <li><a href="#">List one two there</a></li>
    <li><a href="#">List one two there</a></li>
    <li><a href="#">List one two there</a></li>
    <li><a href="#">List one two there</a></li>
    <li><a href="#">List one two there</a></li>
    <li><a href="#">List one two there</a></li>
    <li><a href="#">List one two there</a></li>
</ul>

最佳答案

使用$(this).find('span') $(this).next('span')

关于Jquery改变类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10126290/

相关文章:

javascript - 滚动时如何让div改变不透明度? (视差)

javascript - jQuery UI Datepicker onSelect 清除输入的值

javascript - 跟踪网站上所有访问者的光标移动

javascript - jQueryUI 图标总是显示在顶部而不是内联

javascript - jQuery UI 可选 : Bind to first-generation children only

java - 如何使用 Java 和 Eclipse 在 HTML 网站上启动 Jquery 事件?

javascript - 如何在运行时动态关注输入元素

javascript - 我的visibility_toggle 没有按照我想要的方式工作

javascript - 替换 "hidden input"的替代方案

javascript - 删除元素后可排序的 jQuery-ui 奇怪行为