Put var inside jquery :gt()

后端 未结 2 761
日久生厌
日久生厌 2021-01-12 02:17

I have a list set with display:none and some code to show item 3:

HTML:

  • item 1
  • item 2&
相关标签:
2条回答
  • 2021-01-12 02:53

    You need to delimit the string with the correct quotes. Try this:

    $("li:gt(" + item + "):lt(1)").show();
    
    0 讨论(0)
  • 2021-01-12 02:58

    You have to use double inverted comma for conacatination beacause you use double inverted comma for selector.

    Try this jquery code:

    $("li:gt("+item+"):lt(1)").show();
    
    0 讨论(0)
提交回复
热议问题