Jquery: Action for each change

前端 未结 2 1738
故里飘歌
故里飘歌 2021-01-26 03:44

Continuing on from: https://stackoverflow.com/questions/16649933/jquery-on-form-change-with-bootstrap-sliders/16650319?noredirect=1

I am currently using the below to cap

相关标签:
2条回答
  • 2021-01-26 04:34

    The reason this doesn't work is because JavaScript conforms with the HTML specification, and the HTML specification states that ID attributes must be unique.

    You aren't allowed to have two elements with id="price". Because of this JavaScript will stop searching after it has found the first match. Your .each() loop will only go around once, regardless of how many #price elements are present after the first.

    To resolve this, use classes instead. For example:

    <div class="price">...</div>
    <div class="price">...</div>
    <div class="price">...</div>
    
    $('.price').each(function(index,value) { ... });
    

    You will also need to change your #log elements to use classes, too.

    0 讨论(0)
  • 2021-01-26 04:43

    $('#price') is id, page include one duplicate id. you need use class

    0 讨论(0)
提交回复
热议问题