H
H
Hanna kolesa2015-11-24 13:05:11
CoffeeScript
Hanna kolesa, 2015-11-24 13:05:11

jquery each addClass highlight only the first element, why?

I must say right away that I am not strong in jq. Perhaps the answer is something very simple.
I can not understand why only the first element. I checked in the cookies there are several id
Cookies this is a plugin.

$.each Cookies.get('order_item_ids').split(','), (i, id) ->
    $(".a_schedule_item[data-rental-item-id='" + id + "']").addClass('selected')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Samardak, 2015-11-24
@yaroslav_samardak

Try to debug, for example, output to the console Cookies.get('order_item_ids').split(',')and inside the function console.log i, id, it might help.
Logically, everything seems to be correct.

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question