Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery multiple tag groups in one page
    text
    copied!<p>Related question where I got the scripts:</p> <p><a href="https://stackoverflow.com/questions/4465740/jquery-multiple-tab-groups-on-one-page">jQuery, multiple tab groups on one page</a> <a href="https://stackoverflow.com/questions/3689660/jquery-conflict-with-identical-scripts/3689751#3689751">jquery conflict with identical scripts</a></p> <p>So as the title says I have a page that contains multiple tab groups. the tabs only work on the first group and stops working on the rest.</p> <p>the script:</p> <pre><code> $(function() { $(".tab_content").hide(); $("ul.tabs").each(function() { $(this).find('li:first').addClass("active"); $(this).next('.panes').find('.tab_content:first').show(); }); $("ul.tabs").each(function() { $("ul.tabs li a").click(function() { alert("hello"); var cTab = $(this).closest('li'); cTab.siblings('li').removeClass("active"); cTab.addClass("active"); cTab.closest('ul.tabs').nextAll('.panes:first').find('.tab_content').hide(); var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); </code></pre> <p>The Full HTML:</p> <pre><code>&lt;table id="cform" style="margin-left: 13px;"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt; &lt;form id="form1" name="form1" method="post" action=""&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;b&gt;Subject:&lt;/b&gt; &lt;select name="email_id[]" id="email_id_0" style="width: 350px"&gt; &lt;optgroup label="Emails"&gt; &lt;option value=""&gt;-- Select --&lt;/option&gt;&lt;option value="1"&gt;test(Email)&lt;/option&gt;&lt;option value="2"&gt;test(Email)&lt;/option&gt;&lt;option value="3" selected=""&gt;tesst(Email)&lt;/option&gt; &lt;/optgroup&gt; &lt;optgroup label="SMS"&gt; &lt;/optgroup&gt; &lt;/select&gt; &lt;br&gt; &lt;b&gt;Subject:&lt;/b&gt; &lt;select name="email_id[]" id="email_id_1" style="width: 350px;margin-right: 5;"&gt; &lt;optgroup label="Emails"&gt; &lt;option value=""&gt;-- Select --&lt;/option&gt; &lt;option value="1"&gt;test&lt;/option&gt;&lt;option value="2"&gt;test&lt;/option&gt;&lt;option value="3"&gt;tesst&lt;/option&gt; &lt;/optgroup&gt; &lt;optgroup label="SMS"&gt; &lt;/optgroup&gt; &lt;/select&gt; &lt;center&gt; &lt;input type="button" class="btn-link right" value="Add More" onclick="javascript:addRows();"&gt;&lt;/center&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;br&gt; &lt;div style=" margin-top: 25px; "&gt; &lt;b&gt;Scheduled (Days)&lt;/b&gt; &lt;br&gt; &lt;ul class="tabs"&gt; &lt;li class=""&gt;&lt;a href="#tab1"&gt;Days&lt;/a&gt;&lt;/li&gt; &lt;li class="active"&gt;&lt;a href="#tab2"&gt;Weekly&lt;/a&gt;&lt;/li&gt; &lt;li class=""&gt;&lt;a href="#tab3"&gt;Monthly&lt;/a&gt;&lt;/li&gt; &lt;li class=""&gt;&lt;a href="#tab4"&gt;Yearly&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="panes"&gt; &lt;div id="tab1" class="tab_content" style="padding-top: 20px; display: none;"&gt; days &lt;/div&gt; &lt;div id="tab2" class="tab_content" style="padding-top: 20px; display: block;"&gt; weekly &lt;/div&gt; &lt;div id="tab3" class="tab_content" style="padding-top: 20px; display: none;"&gt; monthly &lt;/div&gt; &lt;div id="tab4" class="tab_content" style="padding-top: 20px; display: none;"&gt; yearly &lt;/div&gt; &lt;/div&gt; &lt;br&gt; &lt;input type="hidden" name="rows_ctr" id="rows_ctr" value="1"&gt; &lt;input type="hidden" name="gid" id="" value="1"&gt; &lt;input type="submit" value="Save" class="btn-link right"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;form&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;b&gt;Subject:&lt;/b&gt; &lt;select name="email_id[]" id="email_id_1" style="width: 350px;margin-right: 5;"&gt; &lt;optgroup label="Emails"&gt; &lt;option value=""&gt;-- Select --&lt;/option&gt; &lt;option value="1"&gt;test&lt;/option&gt;&lt;option value="2"&gt;test&lt;/option&gt;&lt;option value="3"&gt;tesst&lt;/option&gt; &lt;/optgroup&gt; &lt;optgroup label="SMS"&gt; &lt;/optgroup&gt; &lt;/select&gt; &lt;center&gt; &lt;input type="button" class="btn-link right" value="Add More" onclick="javascript:addRows();"&gt;&lt;/center&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;br&gt; &lt;div style=" margin-top: 25px; "&gt; &lt;b&gt;Scheduled (Days)&lt;/b&gt; &lt;br&gt; &lt;ul class="tabs"&gt; &lt;li class="active"&gt;&lt;a href="#tab5"&gt;Days&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tab6"&gt;Weekly&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tab7"&gt;Monthly&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tab8"&gt;Yearly&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="panes"&gt; &lt;div id="tab5" class="tab_content" style="padding-top: 20px; display: block;"&gt; days &lt;/div&gt; &lt;div id="tab6" class="tab_content" style="padding-top: 20px; display: none;"&gt; weekly &lt;/div&gt; &lt;div id="tab7" class="tab_content" style="padding-top: 20px; display: none;"&gt; monthly &lt;/div&gt; &lt;div id="tab8" class="tab_content" style="padding-top: 20px; display: none;"&gt; yearly &lt;/div&gt; &lt;/div&gt; &lt;br&gt; &lt;input type="hidden" name="rows_ctr" id="rows_ctr" value="1"&gt; &lt;input type="hidden" name="gid" id="" value="1"&gt; &lt;input type="submit" value="Save" class="btn-link right"&gt; &lt;/div&gt; &lt;/form&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; </code></pre> <p>Note that this is dynamic hence i can add more groups, the dynamic part is the tr that holds the form.</p> <p>Thank you</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