jQuery [removed]() child selector

前端 未结 3 945
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-28 18:05

I have a ul and i want create an alert when i click on a child li.

    3条回答
    •  自闭症患者
      2021-01-28 18:45

      You can use simply css child selector as below mentioned. It will apply direct children not just any descendant.

      Note: As per http://w3.org standards you can't make the div direct children of ul. The div tag should come inside the li's.

      jQuery("#myul > li").click(function(){
      
          alert('hey!');
      
      });
      

    提交回复
热议问题