javascript - jquery get value of element's grandchild -



i'm trying grab value of input or select (selecting based on grandparent's id), , test if has been set/answered/responded to.

<ul id="foo">     <li>happy text</li>     <li><input name="a" type="text" /></li>     <li><input name="a" type="radio" value="01" />blah</li>     <li><input name="a" type="radio" value="02" />blah</li> </ul>  <ul id="bar">     <li>happy text</li>     <li><input name="b" type="text" /></li>     <li><input name="b" type="radio" value="01" />blah</li>     <li><input name="b" type="radio" value="02" />blah</li> </ul>  <ul id="baz">     <li>happy text</li>     <li>         <select name="c">             <option value="" />             <option value="01">blah</option>         </select>     </li> </ul> 

i've tried few things in javascript (some more successful others):

// question id of grandparent $("#"+question).find("input,select").val(); // kind of works $("#"+question).find("li").children().val(); 

http://jsfiddle.net/jshado1/2ttcf/

edit: don't want values of elements have been answered. want know hasn't been answered. code in fiddle might explain better.

this 1 works ok:

$("#"+question).find(     "input[type!='radio'],input[type='radio']:checked,select" ).val(); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -