I have two select controls on a page, I want to select one of them using a combination of the id and the control type.
If I use the ID and control type, jquery returns a length of 0.
$('#bothCount').text($('#Title select').length);
NB: On some other page, I have an input with id Title, thats why I want to filter down to select controls only.
The selector
…is a descendant selector. It looks for any
selectthat’s a descendant of the element with theidTitle.If you really want to combine tag and
id, you do it like this:E.g.:
Note that there’s usually little point in doing that, though, because
idvalues have to be unique on a page. The only use case I know of for it is if you don’t know what tag the element is going to have and you only want to act on it if it has a particular tag type, which is definitely an edge case.