Must jQuery be verbose? -
i see lot of jquery code this:
if $('#contactme').attr('checked') { $(':radio').attr('disabled', false) } else { $(':radio').attr('disabled', true) }
...but why not way:
var checked = $('#contactme').attr('checked'); $(':radio').attr('disabled', not checked);
...or way:
$(':radio').attr('disabled', not $('#contactme').attr('checked'));
is not possible, or considered ugly/hard maintain?
update
to assertion "not" should "!" (a la c#, etc.), this:
...where works jqueryui-ify button:
$("button:not(:ui-button)").button();
...but this:
$("button:!(:ui-button)").button();
...does not (or should say, "does !")?
you can that, long use !
, not not
.
$(':radio').attr('disabled', !$('#contactme').attr('checked'));
this has nothing jquery, it's how people write things.
Comments
Post a Comment