How to append a listitem in first position of list using Jquery

后端 未结 3 1039
醉酒成梦
醉酒成梦 2021-02-12 19:06

How to append a listitem in first position of list using Jquery?

  • First
  • Second
3条回答
  •  没有蜡笔的小新
    2021-02-12 19:54

    You are selecting the second li element, try this:

    $('#mylist li:eq(0)').before("
  • first
  • "); //or $('#mylist li:first')...

    or you can use prepend method.

提交回复
热议问题