jquery find to get the first element

前端 未结 6 1456
忘掉有多难
忘掉有多难 2020-12-29 19:11

I am writing $(this).closest(\'.comment\').find(\'form\').toggle(\'slow\'); and the problem is each of the forms in the child is being toggled. I would like on

6条回答
  •  不知归路
    2020-12-29 19:37

    Use the below example for jquery find to get the first element

    More filtring methods With Demo

    $(document).ready(function(){
      $(".first").first().css("background-color", "green");
    });
    .first{
        padding: 15px;
        border: 12px solid #23384E;
        background: #28BAA2;
        margin-top: 10px;
    }
    
    
    
    jQuery First Method Example By Tutsmake 
     
    
    
     
    

    This is first() method example

    A paragraph in a div.

    Another paragraph in a div.


    A paragraph in another div.

    Another paragraph in another div.


    A paragraph in another div.

    Another paragraph in another div.

提交回复
热议问题