Botões de alternância de dados HTML5 [FORM]
HTML <div data-toggle=”buttons-radio”><button type=”button” class=”btn” id=”yesBtn” data-info='{“post”:”1″}’>Yes</button><button type=”button” class=”btn” id=”noBtn” data-info='{“post”:”0″}’>No</button></div> CAMPO OCULTO <input type=”hidden” id=”post_to_fb” name=”post_to_fb” value=””> jQuery $(‘#yesBtn’).click(function(e) {e.preventDefault();thisdata = $(‘#yesBtn’).data(‘info’).post;//console.log(thisdata);$(“#post_to_fb”).val(thisdata);});$(‘#noBtn’).click(function(e) {e.preventDefault();thisdata = $(‘#noBtn’).data(‘info’).post;//console.log(thisdata);$(“#post_to_fb”).val(thisdata); });
Continuar lendo