title: JS apply only for first element
body: <p>I need some help to apply js code for all elements, but for now works only for first on each page.</p>
  <p>On page are items with buy buttons, that is created by script, so all buttons have same id but is more than one of them - and I can't apply script that disable button if some condition, only work for first button.</p>
  <pre><code>    &lt;?php $elem = getElement('button_basket'); ?&gt;
      &lt;button disabled = &quot;true&quot; onclick = &quot;checkInput(event)&quot; id=&quot;b1&quot; class=&quot;btn btn-warning btn-lg btn-block tobasket &lt;?php echo $elem['content_tr'] ?&gt;&quot; product_id=&quot;&lt;?php echo $v['id']; ?&gt;&quot; name=&quot;&lt;?php echo $prdata['full_name'] ?&gt;&quot; nametr=&quot;&lt;?php echo $prdata['name1_tr'] ?&gt;&quot; url=&quot;&lt;?php echo $cur_url; ?&gt;catalog/&lt;?php echo $v['img_url']; ?&gt;&quot; price=&quot;&lt;?php echo $v['price']; ?&gt;&quot; &lt;?php if($v['sold']==1) echo 'sold=&quot;true&quot;'; ?&gt;&gt;&lt;?php echo $elem['content'] ?&gt;&lt;/button&gt;
      &lt;?php $elem = getElement('button_oneclick'); ?&gt;
      &lt;p class=&quot;prod-oneclick &lt;?php echo $elem['content_tr'] ?&gt;&quot; &lt;?php if($v['sold']==1) echo 'sold=&quot;true&quot;'; ?&gt;&gt;&lt;?php echo $elem['content'] ?&gt;&lt;/p&gt;
      &lt;script type=&quot;text/javascript&quot;&gt;
      function checkInput(event){
  
      
      &lt;?php
  $cookie_basket = $_COOKIE['basket'];    
  $tempo = urlencode($cookie_basket);
  $countChars = mb_strlen($tempo);
  //echo $countChars;
      ?&gt;
  let test = '&lt;?php echo $countChars;?&gt;';
  let btncheck = document.querySelectorAll('[disabled]');
  //      var step;
  //      for (step = 0; step &lt; 5; step++) {
  if (test &gt; 80){
    document.getElementById(&quot;b1&quot;).disabled = true;
  }else{
    document.getElementById(&quot;b1&quot;).disabled = false;
  }
      }
  //  window.onload = checkInput(event);
  //  }
  &lt;/script&gt;
  </code></pre>
  <p>if will need can provide full page script.</p>