javascript - how to target the first div with jquery? -


i new jquery, please bear me. need find way first div every series of divs same class appears on page can add them specific css styling it. technically need similar :first-child in css.

i tried using .first() got me first div first series of 'divs' class name.

example:

<div class="expl">....</div> <!-- need target div--> <div class="expl">....</div> <div class="expl">....</div>  <h1>....</h1> - example, can have other html tag/content here <div class="expl">....</div> <!-- , div--> <div class="expl">....</div> <div class="expl">....</div>  <p>....</p> <div class="expl">....</div> <!-- , div--> <div class="expl">....</div> <div class="expl">....</div> 

you can use css selector:

*:not(.expl) + .expl 

this target .expl element following non .expl element. can use jquery that, or not, depending on requirements.

working example


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -