有些不起作用,有什么作用?
var tgtCol = $('td[aria-describedby=tblGrid_Subject]');
var tgtHdr = $('#tblGrid_Subject');
$(tgtHdr, tgtCol).attr('colSpan', '3');
答案 0 :(得分:13)
var tgtCol = $('td[aria-describedby=tblGrid_Subject]');
var tgtHdr = $('#tblGrid_Subject');
$(tgtHdr).add(tgtCol).attr('colSpan', '3');
这也有效:
var stuff = $('td[aria-describedby=tblGrid_Subject], #tblGrid_Subject');
stuff.attr('colSpan', '3');
答案 1 :(得分:1)
你很接近,你可以用逗号组合多个选择器,如下所示:
$('td[aria-describedby=tblGrid_Subject], #tblGrid_Subject').attr('colSpan', '3');
答案 2 :(得分:1)
由于前两行已经返回一个jQuery对象,你可以这样做:
tgtHdr.attr('colSpan', '3');
tgtCol.attr('colSpan', '3');
答案 3 :(得分:0)
您最初可以使用multiple selector:
$('td[aria-describedby=tblGrid_Subject], #tblGrid_Subject').attr('colSpan', '3');
答案 4 :(得分:0)
如果它是两个选择器,您可以使用' merge'但如果它超过两个,您应该使用'每个'
// using merge:
$.merge(selector1, selector2) // the rest
// using each:
$([selector1, selector2, selector3, .....etc]).each(function(){
// your code here
});