How can I enable one specific tab by clicking the button?

EliaFardi
$(document).ready(function() {
  $('.tabs').tabs();
  $("#btnContinue").click(function() {
    $("#test2").attr("disabled", "false");
  });
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<div class="col s12">
  <ul class="tabs">
    <li class="tab col s3"><a href="#test1">Test 1</a></li>
    <li class="tab col s3 disabled"><a href="#test2">Test 2</a></li>
    <li class="tab col s3 disabled"><a href="#test3">Disabled Tab</a></li>
    <li class="tab col s3 disabled"><a href="#test4">Test 4</a></li>
  </ul>
</div>

<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>

<div class="modal-content" id="test1">
  <h4>Register</h4>
  <p>A bunch of text</p>
  <form id="signup-form">
    <div class="input-field">
      <input type="email" id="signup-email" required />
      <label for="signup-email">Email address</label>
    </div>
    <div class="input-field">
      <input type="password" id="signup-password" required />
      <label for="signup-password">Choose password</label>
    </div>
    <button class="btn yellow darken-2 z-depth-0" id="btnContinue">Continue</button>
  </form>
</div>

My idea is that I have 4 tabs and 3 of them are disabled(I used materialize css). If the user enter his Email and his Password and then presses the button, the tab 2 should be enabled(only tab2).

uingtea

in your code, disabled is not attribute/property but class, on button click add class disabled to all tab but remove from the second tab.

$(document).ready(function() {
  $('.tabs').tabs();
  
  $("#btnContinue").on('click', function(e) {
    e.preventDefault(); // <== disable form submit
    $('.tab').addClass('disabled');
    var secondTab = $('.tab').eq(1)
    secondTab.removeClass('disabled', false)
    secondTab.find('a')[0].click(); // switch tab
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<div class="col s12">
  <ul class="tabs">
    <li class="tab col s3"><a href="#test1">Test 1</a></li>
    <li class="tab col s3 disabled"><a href="#test2">Test 2</a></li>
    <li class="tab col s3 disabled"><a href="#test3">Disabled Tab</a></li>
    <li class="tab col s3 disabled"><a href="#test4">Test 4</a></li>
  </ul>
</div>

<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>

<div class="modal-content" id="test1">
  <h4>Register</h4>
  <p>A bunch of text</p>
  <form id="signup-form">
    <div class="input-field">
      <input type="email" id="signup-email" required />
      <label for="signup-email">Email address</label>
    </div>
    <div class="input-field">
      <input type="password" id="signup-password" required />
      <label for="signup-password">Choose password</label>
    </div>
    <button class="btn yellow darken-2 z-depth-0" id="btnContinue">Continue</button>
  </form>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I enable tabs by clicking on the button?

From Dev

How can I close a Javafx 2.2 Tab when clicking a save/cancel button inside it?

From Dev

How can I restart application by clicking a button?

From Dev

How can I add a row to a ListView in one Fragment by clicking the button in another Fragment?

From Dev

How can I extend JComboBox to allow user to remove list items by clicking an x button, like an Internet browser tab?

From Dev

How can I extend JComboBox to allow user to remove list items by clicking an x button, like an Internet browser tab?

From Dev

How do I change one image to another upon clicking on a button

From Dev

Go to a specific tab through clicking a specific button in html

From Dev

How can I see a list from the browsers by clicking on a button

From Dev

How can I add an Action after clicking on an ActionBar's Button?

From Dev

How can i change background color of my layout by clicking a Button

From Dev

Swift: How can I open a new window clicking a button?

From Dev

How i can clear the WebView's content with javaFX by clicking on a button?

From Dev

How can I open an URL using PyQt when clicking on a button?

From Dev

How can I add another TextInput by clicking a button?

From Dev

How can I disable clicking sound for Action Menu button?

From Dev

How Can I Change Strings.xml by Clicking a Button?

From Dev

jQuery: enable 2nd button after clicking on the first one

From Dev

how to go to other Tab by clicking button inside the current Tab in bootstrap

From Dev

How can I hide popovers on page when clicking a new one?

From Dev

How can I enable the UITextField to have only one text/number and navigate through multiple `UITextField`s using Next / Done Button

From Dev

How can I disable/enable submit button after jQuery Validation?

From Dev

How can i enable/disable a button in a backgroundworker DoWork event?

From Dev

How can I enable the power button on my server?

From Dev

How can I enable a button on field change using bootstrap and jQuery

From Dev

How can I enable App Sandboxing for specific build configuration

From Dev

How can I enable App Sandboxing for specific build configuration

From Dev

How can I open a specific Tab View from AppDelegate

From Dev

How can I add a specific page to the 'New Tab' page?

Related Related

  1. 1

    How can I enable tabs by clicking on the button?

  2. 2

    How can I close a Javafx 2.2 Tab when clicking a save/cancel button inside it?

  3. 3

    How can I restart application by clicking a button?

  4. 4

    How can I add a row to a ListView in one Fragment by clicking the button in another Fragment?

  5. 5

    How can I extend JComboBox to allow user to remove list items by clicking an x button, like an Internet browser tab?

  6. 6

    How can I extend JComboBox to allow user to remove list items by clicking an x button, like an Internet browser tab?

  7. 7

    How do I change one image to another upon clicking on a button

  8. 8

    Go to a specific tab through clicking a specific button in html

  9. 9

    How can I see a list from the browsers by clicking on a button

  10. 10

    How can I add an Action after clicking on an ActionBar's Button?

  11. 11

    How can i change background color of my layout by clicking a Button

  12. 12

    Swift: How can I open a new window clicking a button?

  13. 13

    How i can clear the WebView's content with javaFX by clicking on a button?

  14. 14

    How can I open an URL using PyQt when clicking on a button?

  15. 15

    How can I add another TextInput by clicking a button?

  16. 16

    How can I disable clicking sound for Action Menu button?

  17. 17

    How Can I Change Strings.xml by Clicking a Button?

  18. 18

    jQuery: enable 2nd button after clicking on the first one

  19. 19

    how to go to other Tab by clicking button inside the current Tab in bootstrap

  20. 20

    How can I hide popovers on page when clicking a new one?

  21. 21

    How can I enable the UITextField to have only one text/number and navigate through multiple `UITextField`s using Next / Done Button

  22. 22

    How can I disable/enable submit button after jQuery Validation?

  23. 23

    How can i enable/disable a button in a backgroundworker DoWork event?

  24. 24

    How can I enable the power button on my server?

  25. 25

    How can I enable a button on field change using bootstrap and jQuery

  26. 26

    How can I enable App Sandboxing for specific build configuration

  27. 27

    How can I enable App Sandboxing for specific build configuration

  28. 28

    How can I open a specific Tab View from AppDelegate

  29. 29

    How can I add a specific page to the 'New Tab' page?

HotTag

Archive