Live search through table rows

前端 未结 15 1867
失恋的感觉
失恋的感觉 2020-11-29 00:52

I want to do a live search through the table rows, using jQuery, the \"live\" word is the key, because I want to type the keywords in the text input, on the same site and I\

15条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 01:10

    I took yckart's answer and:

    • spaced it out for readability
    • case insensitive search
    • there was a bug in the comparison that was fixed by adding .trim()

    (If you put your scripts at the bottom of your page below the jQuery include you shouldn't need document ready)

    jQuery:

     
    

    If you want to extend this have it iterate over each 'td' and do this comparison.

提交回复
热议问题