Check if a div variant exists

4

I have several divs with the class prefix "webserver_ [..]" and I would like to check if any div with the prefix "webserver_ [..]" exists with jQuery only,     

asked by anonymous 11.01.2015 / 00:26

1 answer

5

You can use ^= which is a pseudo-selector which means that a given attribute "starts with" and then look for elements whose class begins with this string "webserver _".

Example:

$('[class^="webserver_"]').length // vai dar o numero de divs existentes

jsFiddle: link

    
11.01.2015 / 00:30