javascript - jquery + coffeescript search box that hides list elements -


i trying create search box hides ul , li elements depending on text.

$(document).ready ->     $('input#barcode').on "keyup", ->         search = $(this).val()         $('li.barcode').each ->             $(this).parent().fadeout('fast') unless $(this).text().indexof search == 0 

i want know how use fat arrows (=>) make code better.

i've fixed it!!

$(document).ready ->     $('#barcode').on "keyup", ->         search = $(@).val()         $('.barcode').each ->             $(@).parent().fadeout('fast') unless $(@).text().indexof(search) == 0 

i still don't know how use fat arrows. , think make code nicer. can me it?

if understand documention, know how/why use fat arrow.

and can try:

$ ->     $('#barcode').on "keyup", ->         search = $(@).val()         $('.barcode').each ->             $(@).parent().fadeout('fast') unless $(@).text() search 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -