我目前正在选择所有class为.follow-container的元素,以下是代码:
$('.follow-container').html('it's this one');
如何仅选择具有类和属性onmousedown="alert()"
的元素?
我目前正在选择所有class为.follow-container的元素,以下是代码:
$('.follow-container').html('it's this one');
如何仅选择具有类和属性onmousedown="alert()"
的元素?
$('.follow-container[number="3"]')
提醒一下,您应该使用数据属性而不是不支持的number
属性。
那么使用data-number="3"
如何呢?
您可以使用以下方式进行选择:
$('.follow-container[data-number="3"]');
如果您更喜欢使用自己的属性,可以使用以下方式:
$('.follow-container[number="3"]');
这是代码片段:
$('.follow-container').each(function(idx, ele)
{
if($(ele).attr('onmousedown') == 'alert()')
{
// do stuff to $(ele)
// $(ele) is the element you want!
}
});
onmousedown
的内容基本上就是一个脚本!o.O - radixhound