lundi 16 octobre 2017

If checkbox is checked, activate field [jQuery, Semantic UI]

I am a beginner and i need some help. In my code I use jQuery and Semantic-ui. I try to activate text input after i checked the checkbox input.

When checkbox is checked class change from class="ui slider checkbox " to class="ui slider checkbox checked". To activate text input i need to change class="disabled field" to class="field".

Links: http://ift.tt/2zssh9t http://ift.tt/2zeweOe

<html>
    <head>
        <title> ASD</title>
        
        <link rel="stylesheet" type="text/css" href="http://ift.tt/2wTEiGM">
        <script src="http://ift.tt/2nX6jVx"></script>
        <script src="http://ift.tt/2ztIHhJ"></script>
           
    </head>
    <body>


<div class="inline field">
    <div class="ui slider checkbox">
      <input type="checkbox" tabindex="0" class="hidden">
      <label>Imprumutata</label>
    </div>
  </div>
      
      <div class="ui equal width form">
    <div class="disabled field">
      <label>Data</label>
      <input placeholder="Data" type="text" disabled="" tabindex="-1">
    </div>
</div>
      
      
      
       <script>
            $('.ui.accordion').accordion();
        </script>
        <script>
            $('.ui.dropdown').dropdown();
        </script>
        <script>
            $('.ui.checkbox').checkbox();
        </script>
       
       
       
       
      // this is what i tried
        <script>
            if($(".ui.checkbox").is('.ui.checkbox.checked'))
                $(".ui.disabled.field").addClass(".ui.field");  // checked
            else
                $(".ui.disabled.field").addClass(".ui.disabled.field");  // unchecked
        </script>
    </body>
</html>



Aucun commentaire:

Enregistrer un commentaire