0
alert($("#bottomTbodyTable tr [data-testlog]").length); // display value 0
alert($("#bottomTbodyTable tr").data("testlog")); // display the correct value

この属性の表示中に明らかに値がある場合、値 0 を理解できません。

4

1 に答える 1

3

あなたはおそらく欲しかった

$("#bottomTbodyTable tr[data-testlog]").length

これは、 と の間trにスペースがない場合と同じです。スペース[data-testlog]は、 data 属性を持つ要素が の子孫であることを意味しますtr

于 2013-04-15T18:26:42.067 に答える