使用jQuery删除第一李 [英] delete first li using jquery

查看:287
本文介绍了使用jQuery删除第一李的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只能删除li中的第一个元素吗?

例如:


  • type1
  • type2
  • Hi, can i delete only first element in li?

    for example:


    • type1
    • type2
    • 推荐答案

      您可以给li元素(例如"l1","l2"等)使用ID,并使用 jQuery的方法,您可以像followng一样将其删除.


      You can give an id to to the li elements like "l1", "l2" etc. and using the remove method of jQuery you can remove it like followng.



      ("#l1").remove();
      ("#l1").remove();


      假设您下面有类似UL的项目

      Suppose you have UL item like this below

      <ul>
      <li>Type1</li>
      <li>Type2 </li>
      </ul>



      然后您的jquery代码将是



      Then your jquery code will be


      这篇关于使用jQuery删除第一李的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆