title: How to access a row which is dynamically created in GOHTML template?
body: <p>In my GOHTML file, I am dynamically creating table rows from the results using range. Further, I want to access each row for operations like edit or delete. For example: Click on a row should open a modal with its values. But, with my current implementation the modal is appearing only on the first row. Click doesn't work on rest of the rows. </p>
  
  <p><strong>Table :</strong>   </p>
  
  <pre><code>&lt;table&gt;
  {{range .Bdata}}
  
      &lt;tr class="buy" id="trx_buy"&gt; 
            &lt;td&gt;{{.Sname}}&lt;/td&gt; 
            &lt;td align="center"&gt;{{.Uprice}} &lt;/td&gt; 
            &lt;td align="center"&gt;{{.Qty}} &lt;/td&gt;
            &lt;td align="center"&gt;{{.Bfee}}&lt;/td&gt;
            &lt;td align="center"&gt;{{.Tprice}}&lt;/td&gt;
            &lt;td align="center"&gt;{{.Fdate}}&lt;/td&gt;
       &lt;/tr&gt; 
          {{end}}
        &lt;/table&gt;
  </code></pre>
  
  
  
  <pre><code>&lt;div class="modal-content"&gt;
      &lt;span class="close"&gt;&amp;times;&lt;/span&gt;
      &lt;p&gt;{{.Sname}}, {{.Uprice}} &lt;/p&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Script to handle onclick :</strong> </p>
  
  <pre><code>&lt;script&gt;
  // Get the modal
  var modal = document.getElementById("myModal");
  
  var tr_buy = document.getElementById("trx_buy");
  
  // Get the &lt;span&gt; element that closes the modal
  var span = document.getElementsByClassName("close")[0];
  
  tr_buy.onclick = function() {
    modal.style.display = "block";
  }
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  span.onclick = function() {
    modal.style.display = "none";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  window.onclick = function(event) {
    if (event.target == modal) {
      modal.style.display = "none";
    }
  }
  &lt;/script&gt;
  </code></pre>