>  No, but....
>
>  I am generating XML to send to my server.  I was replacing what was
>  basically
>
>  var xmlString = "<foo state="' + document.all.ProtectLocal.checked +
>  '"/>';
>
>  with
>
>  var xmlString = "<foo state="' + $('#ProtectLocal').attr("checked") +
>  '"/>';
>
>  Because I like the jQuery way of specifying items.  And the above
>  makes more sense then what is actually needed:
>
>  var xmlString = "<foo state="' + $('#ProtectLocal').attr("checked") ?
>  true : false + '"/>';
>
>  jQuery makes my code so much more readable and allows me to remove a
>  lot of existing JavaScript, this would be the first time it resulted
>  in more JavaScript to do the same thing.
>
>  -= chuck
>

I hear what you're saying.  jQuery is simply returning the results of
element.getAttribute('checked') and if the attr does not exist then
its value is undefined.  Not sure whether that's a bug or not though.
A slightly more compact syntax would be:

var xmlString =
'<foo state="' + ($('#ProtectLocal').attr("checked")||false) + '"/>';

Reply via email to