我有以下代码:
$ (document).ready(function(){
$('tr:nth-child(odd)').addClass("alt");
});
<小时/>
我希望 tr:nth-child(odd)
仅对以 'tr[id^="part"]'
开头的表行执行。
我该怎么做?我对此有点陌生,需要一些帮助。
最佳答案
您可以尝试使用multiple attribute选择器:
$('tr[:nth-child(odd)][id^="part"]').addClass("alt");
关于javascript - 结合jquery选择器对定义的选择执行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21235596/