vendredi 9 mars 2018

JavaScript or Jquery: as long as it works, how to enable checkbox when checked

Here's my code:
HTML:

    <input type="checkbox" id="checkme"/>
                        <p class="label-text"><b>By checking this, you agree to our <a href="terms.html" onclick="window.open(this.href, 'mywin',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" style="color: red;">Terms &amp; <br>Conditions</a>&nbsp;and&nbsp;<a href="privacy.html" onclick="window.open(this.href, 'mywin',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" style="color: red;">Privacy Policy</a></b></p>
    <input class="formBtn" type="submit" id="submit" value="Submit" disabled="disabled" />

JavaScript

var checker = document.getElementById('checkme');
         var sendbtn = document.getElementById('submit');
         checker.onchange = function(){
        if(this.checked){
            sendbtn.disabled = false;
        } else {
            sendbtn.disabled = true;
        };

jQuery

$( "#checkme" ).on( "click", function() {
          if($( "#checkme:checked" ).length > 0)
          {
            $('#submit').prop('disabled', false);
          }
          else
          {
            $('#submit').prop('disabled', true);
          }  
        });

all not working. :( pls help

also help me add in the javascript a class for css to make the button transparent when disabled. thanks a lot!




Aucun commentaire:

Enregistrer un commentaire