I have a code where when a user selects a check box the label will turn into a link to submit the form. I can get the label to change to a link but when I use the link as a submit button it only returns the url with # Here’s what I’ve tried.
$('#checkbox').change(function() {
var c = this.checked ? '#f00' : '#09f';
$('label').css('color', c);
var $this = $(this);
$('label').wrap('<a href="#" id="sublink"></a>');
$('a').link('href', '#');
});
$('#sublink').bind('click', function() {
$('#formname').submit();
});
Thank you 🙂
Delegate the event
body can be replaced with any static parent container which encases the anchor Tag.
The closer the better
UPDATE