jquery radio buttons

Can I treat radio buttons the same as other fields in my form for the purposes of jquery script
Can I use

$("#example").change(function(e)

if (e.target.value==‘Yes’)

Or do I have to use a different method?

http://api.jquery.com/checkbox-selector/

Looks like this answers your question: http://stackoverflow.com/a/7031408

This isn’t the place to post links to other forums Answer the question or don’t

You would be more likely to get helpful answers if you ever said thanks
when people here do help you.
For example your post with subject "conditional validatiobs" (whatever that
means) on 29th March.

Colin

Agreed. Politeness and kindness goes a long way.

Then thanks and sorry and sorry to James too I didn’t mean to be unpolite or ungracious although we need our forum we can’t just link to answers on others

To answer my own question A: Yes; The reason it didn’t work is because rails actionview radio button helper creates radio buttons which successfully relay info on form submission but actually the html it renders leaves out a foward slash for the closing greater than sign > should be /> so it causes jquery not to pick it up properly; maybe, that’s how i fixed it i think

I do delete my invalid unanswered questions although there’s a lag

  This isn't the place to post links to other forums Answer the question
or don't

You would be more likely to get helpful answers if you ever said thanks
when people here do help you.
For example your post with subject "conditional validatiobs" (whatever
that means) on 29th March.

Colin

I do delete my invalid unanswered questions although there's a lag

No you don't, they still appear in my inbox. It is impossible for you to
deleted them from there.
Also there is no reason not to reply by pointing to an answer that already
exists out on the web. Whether it is in a reply on another support group or
on a web page somewhere or a reference to some docs. Do you suggest that we
copy and paste the answer here, so filling the web up with duplicate data?
It is a lot easier for you to click on a link than it is for someone else
to copy/paste a reply from elsewhere. You should be grateful that he/she
took the time to look it up for you.

Colin

Rails since v3 has used HTML5 for its templating language by default. If you haven't changed anything, that's the expectation. HTML5 allows but does not require the "self-closed" tags of XHTML -- <hr /> and <hr> are equivalent, IOW.

In my (admittedly limited) experience with jQuery (I have far more experience with Prototype), I doubt very much that the trailing slash had anything to do with the matcher. Both Prototype and jQuery use the Sizzle matcher, and it's extremely good. More likely, you may have inadvertently written invalid HTML (regardless of level) including multiple items with the same ID attribute. It's always a good first step when diagnosing JavaScript weirdness to view source in a browser, copy it, and paste it into https://validator.w3.org to see if there are any obvious errors. jQuery won't complain if you use the same ID twice (or more) in a page, but it will do unpredictable things when you try to access an attribute or value.

Finally, the Rails checkbox / radio button helper provides an empty same-name hidden variable for each item that needs one, since in all HTML/CGI interfaces, the lack of a checkbox does not send a foo=false in a form post, it just does not send foo at all. Thus you will see this construction in your radio buttons:

  <input type="hidden" name="foo" value="" />
  <input type="radio" name="foo" value="bar" />
  <input type="radio" name="foo" value="baz" />

This means that the foo key will be present in all of your submissions, regardless if any of the options are checked or not. This is of much more importance in checkboxes than radio buttons, since without it, there would be no way to "un-check" a checkbox using an HTML form.

Walter