JQuery selector not working correctly

Well, I can’t understand what I'm doing wrong here ...

Take the following jQuery selector ...

$('tr[batchid]:has(span.chkselb input:checked) span[id=assetcount]')

Returns 2 items. But if I make the following selector:

$('tr[batchid]:has(span.chkselb input:checked) span#assetcount')

This returns 0 elements. Are these two selectors for all goals and objectives not identical?
Or is there some kind of weird interaction with the ": has" operator or something else? I got it working with the first expression, but I'm really curious why the second (my original selector) is not working. Any ideas?

+3
source share
1 answer

$('tr[batchid]:has(span.chkselb input:checked) span[id=assetcount]') should not return two elements, since identifiers must be unique.

, , , , , tr[batchid]:has(span.chkselb input:checked), .

.

+6

Source: https://habr.com/ru/post/1723702/


All Articles