Get the ID of div tag which is being displayed using jquery

 This code will show you how to get the ID of div tag which is being displayed using jquery

The HTML code will look like

<div id="skills">
<div class="items" id="items1" style="display:none">1</div>
<div class="items" id="items2" >2</div>
<div class="items" id="items3" style="display:none">3</div>
<div class="items" id="items4" style="display:none">4</div>
<div class="items" id="items5" style="display:none">5</div>
</div>

Observe that class name is same so we will use class name to get the ID of div tag which is being displayed

var divId = $("div.items").not(":hidden").prop("id");
The above jquery code will give you the div id

Tags: No tags

Leave A Comment

Your email address will not be published. Required fields are marked *