I'm not quite sure what you are trying to achieve here, so please forgive me if my answer is not what you were looking for. If you want a button that changes the state of the flag, then @thecodeparadox's answer should work fine, however if you are looking for a button that executes a function but also has a flag inside it that you can switch, you might want something like the following:
HTML:
<div id="button" href="#"> <input type="checkbox" class="check">Submit </div>
CSS
body { margin: 10px; } #button { display: inline-block; background: #ddd; border: 1px solid #ccc; padding: 5px 10px; text-decoration: underline; color: blue; cursor: pointer; } .check { display: inline-block; margin-right: 10px; }
JQuery
$('#button').on('click', function() { window.location = '#'; })
http://jsfiddle.net/QStkd/278/
user354346
source share