Need help with jquery tab plugins

I use the following code as a tab plugin

//When page loads...
 $("#searchbox .tab_content").hide(); //Hide all content
 $("#searchbox ul.tabs li:first").addClass("active").show(); //Activate first tab
 $("#searchbox .tab_content:first").show(); //Show first tab content
//alert($("ul.tabs li:last").find("a").attr("href"));
 //On Click Event
 $("#searchbox ul.tabs li").click(function() {

  $("#searchbox ul.tabs li").removeClass("active"); //Remove any "active" class
  $(this).addClass("active"); //Add "active" class to selected tab
  $("#searchbox .tab_content").hide(); //Hide all tab content

  var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
  $(activeTab).fadeIn(); //Fade in the active ID content
  return false;
 });

my html page contains 4 list items as a menu. When a page refreshes, it always loads the contents of the first element, as shown in the code. Each link to a div has its own corresponding form. If I name the same page in the action form, how can I download the relevant content. means that if I submitted a rental form for search, and then when the page refreshes, it should display a container for rental search instead of li: first

+3
source share
1 answer

, li.

:

<form method="post">
  <input type="hidden" name="activetab" value="" />
  ...
</form>

, id li, , :

$("#searchbox ul.tabs li").click(function() {
    $("input[name=activetab]").val($(this).attr("id"));
});

, PHP, :

foreach($tab_id_array as $tab_id) { ?>
<li class="<?= ($_POST["activetab"]==$tab_id) ? "active" : "" ?>"><?= $tabcontent ?></li>
<? } ?>
+1

Source: https://habr.com/ru/post/1782903/


All Articles