Jquery event on wrapped input radio override 'checked' event -


i want check , uncheck (toggle) radio when "td" click preserving default input event

<table>    <tr>       <td>           <input type='radio'>       </td>    </tr> </table> 

my code attempts:

try 1: http://jsfiddle.net/ujxru/

try 2: http://jsfiddle.net/ujxru/1/

try 3: http://jsfiddle.net/ujxru/2/

preview:

$("td").click(function(e) {     if (!$(e.target).is("input")) {         var bool = !$(this).children("input").is(':checked');         $(this).children("input").attr("checked", bool)     }     else{         var bool2 = !$(e.target).is(':checked');         $(e.target).attr('checked',bool2);     } }); 

try out..

$("td").click(function(e) {     if (e.target.type !== 'radio') {         $(this).find(":radio").trigger('click');     } }); 

example on jsfiddle.

if want make td , radio button toggle radio checked property this:

$("td").toggle(function() {     $(this).children(":radio").attr("checked", true); }, function() {     $(this).children(":radio").attr("checked", false); }); 

example on jsfiddle


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -