_lhermann’s avatar_lhermann’s Twitter Archive—№ 138

  1. …in reply to @iamrockyclark
    @RockyClark1 @CodePen Here is the fixed version: codepen.io/lhermann/pen/jgGeNg?editors=1000 I changed id='addToMap' to data-btn='addToMap' and queried for the data attributes. Then you get an array. You have to iterate over the array and attach a click handler to each button individually ...
    1. …in reply to @_lhermann
      @RockyClark1 @CodePen ... Then JS has to know which input element to check, so you use button.previousElementSibling to get the sibling. I also added a "name" attribute so JS knows which key to use for the value. Let me know if you have any further questions 😀