vendredi 15 février 2019

Click event if element is checked and reload page

I would like a reload.location click-event only if a checkbox is checked. To me this seems to be basic conditions, but it's not working. Perhaps a different approach is needed? What I figured out, is when the checkbox is ticked, there is no html change in the <input type="checkbox"> element. Maybe this is the reason or is the combination of these conditions not possible?

My attempt:

$('#button').click( function() {
    if( $('#checkbox').checked ) {
        location.reload(true);
    }
});

Aucun commentaire:

Enregistrer un commentaire