jquery addclass removeclass onclick 表单标签
我有一个非常简单的 addclass、removeclass 函数,我想在 onclick 上执行它,如下所示:
$('#filter').click(function() {
$(this).closest('fieldset').find('.selectedfilter').removeClass('selectedfilter');
$(this).parent().addClass('selectedfilter');
});
david thomas 为此提供了一个很好的 jsfiddle: http://jsfiddle.net/davidThomas/eMx7X/
我有一个 id 为“filter”的表单其中包含(隐藏)单选按钮和可单击的(可见)标签。活动类应用于在页面加载时检查的标签,并且在单击时应更改为另一个标签。
但是,jquery 函数在此页面上不起作用: http://www.alexbrunner.com/travels/。不仅addclass、removeclass不起作用,quicksand插件也不起作用(它可以很好地过滤和排序后续列表中的项目,而无需短的 .click 功能)也停止工作。
我对问题出现的地方很迷茫。我非常感谢对此的任何帮助! 这些文件位于:
http://www.alexbrunner.com/travels/
http://www.alexbrunner.com/style.css(“quicksand shuffle”部分中的相关行)
i have a quite a simple addclass, removeclass function which i want to execute onclick, like so:
$('#filter').click(function() {
$(this).closest('fieldset').find('.selectedfilter').removeClass('selectedfilter');
$(this).parent().addClass('selectedfilter');
});
david thomas provided a nice jsfiddle for exactly this:
http://jsfiddle.net/davidThomas/eMx7X/
i have a form with the id 'filter' which contains (hidden) radio buttons and (visible) labels which are clickable. the active class is applied to the label which is checked on page load and should be changed to another label when clicked.
however, the jquery function does not work on this page: http://www.alexbrunner.com/travels/. not only does the addclass, removeclass not work, but also the quicksand plugin (which filters and sorts the items in the subsequent list just fine without the short .click-function) also stops working.
i am quite lost where the problem arises. i would very much appreciate any help on this!
the files are live at:
http://www.alexbrunner.com/travels/
http://www.alexbrunner.com/style.css (relevant lines in section 'quicksand shuffle')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查 Firebug 中的页面 - 您有一个 javascript 错误:
您可以在
click()
方法末尾看到该字符。Check the page in Firebug - you have a javascript error:
You can see the character at the end of the
click()
method.