Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should refer to each dropdown using its class rather than the ID which, as you know, must be unique. IF you repeat the above code several times, you'll still be adressing only the first dropdown .</p> <p>HTML:</p> <pre><code> &lt;tr&gt; &lt;td&gt;1.&lt;/td&gt; &lt;td&gt; &lt;!-- Single button --&gt; &lt;div class="btn-group" class="MACdropdown" id="MACdropdown1"&gt; &lt;button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown"&gt; Action &lt;span class="caret"&gt;&lt;/span&gt; &lt;/button&gt; &lt;ul class="dropdown-menu"&gt; &lt;li&gt;&lt;a class="move" href="#"&gt;Move Assets&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="swap" href="#"&gt;SWAP Assets&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="add" href="#"&gt;Add Assets&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="cancel" href="#"&gt;Cancel Assets&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="change" href="#"&gt;Change Assets&lt;/a&gt;&lt;/li&gt; &lt;li class="divider"&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Entire Site Move&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt;4534-23423&lt;/td&gt; &lt;td&gt;123-234&lt;/td&gt; &lt;td&gt;346&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>JS:</p> <pre><code>$(document).ready(function(){ $(".MACdropdown").on('click' , 'a.move' , function(){ $(this).closest('.MACdropdown').replaceWith('&lt;a href="viewassets-move.html"&gt;&lt;span class="label label-danger"&gt;MOVE&lt;/span&gt;&lt;/a&gt;'); }) $(".MACdropdown").on('click' , 'a.swap' , function(){ $(this).closest('.MACdropdown').replaceWith('&lt;a href="viewassets-move.html"&gt;&lt;span class="label label-danger"&gt;SWAP&lt;/span&gt;&lt;/a&gt;'); }) $(".MACdropdown").on('click' , 'a.add' , function(){ $(this).closest('.MACdropdown').replaceWith('&lt;a href="viewassets-move.html"&gt;&lt;span class="label label-danger"&gt;ADD&lt;/span&gt;&lt;/a&gt;'); }) $(".MACdropdown").on('click' , 'a.cancel' , function(){ $(this).closest('.MACdropdown').replaceWith('&lt;a href="viewassets-move.html"&gt;&lt;span class="label label-danger"&gt;CANCEL&lt;/span&gt;&lt;/a&gt;'); }) $(".MACdropdown").on('click' , 'a.change' , function(){ $(this).closest('.MACdropdown').replaceWith('&lt;a href="viewassets-move.html"&gt;&lt;span class="label label-danger"&gt;CHANGE&lt;/span&gt;&lt;/a&gt;'); }) }); </code></pre> <p>As you see, I'm not using ids at all. Each select behaves the same, and its children controls just affect him (you could also use the parent selector instead of closest('.MACDropdown') but I chose the latter in case you change a bit your layout.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload