Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to use jQuery :first Selector?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 393
    Comment on it

    Hi Reader's,
     Welcome to FindNerd, today we are going to discuss how to use jQuery :first Selector?

     Basically :first selector is used for selecting the first element and it is always use in a group.
     The :first selector  can only select one single element.

    syntax of :first Selector


    You can see below example for better understanding:

    <!DOCTYPE html>
        <script src=""></script>
       <!-- start css part -->
          #paragraph {
                  max-width: 600px;
                  margin: 0 auto;
       <!-- end css part -->
          //call here :first Selector and also put css for effect
            $("p:first").css("background-color", "green");
       <div id = "paragraph">
          <p>First paragraph.</p>
          <p>Second paragraph.</p>
          <p>Last paragraph.</p>

    In above code you can see First Parameter will be selected with green color.


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: