jQuery: Check if div with certain class name exists

Using jQuery I’m programmatically generating a bunch of div‘s like this:

<div class="mydivclass" id="myid1">Some Text1</div>
<div class="mydivclass" id="myid2">Some Text2</div>

Somewhere else in my code I need to detect if these DIVs exist. The class name for the divs is the same but the ID changes for each div. Any idea how to detect them using jQuery?

19 Answers
19

Leave a Comment