选择 .button 其中 data-source 等于 all

Posted

技术标签:

【中文标题】选择 .button 其中 data-source 等于 all【英文标题】:Select .button where data-source equals all 【发布时间】:2012-08-17 07:44:27 【问题描述】:

正如问题标题中提到的,我正在尝试选择 a.button 其中 :data(source==all) 但没有成功,这是我尝试过的

$('.button:data("source==all")').css('background', 'red');
$('#sources-list li').find('.button:data("source==all")').css('background', 'red');
$('#sources-list li').find('.button:data("source=all")').css('background', 'red');

还有其他想法吗?

【问题讨论】:

【参考方案1】:

我想你想要

$('a.button[data-source=all]').css('background', 'red');

【讨论】:

【参考方案2】:

试试这个:

$('.button').filter(function()
    return $(this).data('source') == "all"
).css('background', 'red');

【讨论】:

以上是关于选择 .button 其中 data-source 等于 all的主要内容,如果未能解决你的问题,请参考以下文章

如何动态添加按钮?

关于mfc中radio button

选择行时启用自定义按钮(默认禁用)

流光小部件依赖

android 怎样让两个button控件挨在一起,左右对齐 没有距离?

如何在 <button> 元素中使用光标选择文本?