jQuery first method


jQuery first method() is used to get the first element of the selected element.


Syntax : jQuery first method

$(selector).first();

Note : It accepts no arguments.

jQuery first method Example

jQuery first() Method – Example

<script type="text/javascript">
         $(document).ready(function(){ 
              $("li.second-li >ul >li").first().css("background","yellow");               
          });
</script>

Try it »


Advertisements

Add Comment

📖 Read More