Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery, how to retrieve a set of values
    primarykey
    data
    text
    <pre><code> var $ds=$('.stars-wrapper1').each(function(i) { alert($(this).find(':first').attr('title')); }); </code></pre> <p>I wan to get the attribute of each first child from each stars-wrapper1 class, in my code.</p> <p>Here is how it looks:</p> <pre><code> &lt;div class="stars-wrapper1"&gt; &lt;input type="radio" name="newrate" value="1" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="2" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="3" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="4" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="5" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="6" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="7" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="8" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="9" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;input type="radio" name="newrate" value="10" title="&lt;?php echo $commentID;?&gt;" /&gt; &lt;/div&gt; </code></pre> <p>I want to get the title.. But all I get is an empty value in the alert. Note: I have several classes named stars-wrapper1..so I have to iterate over them and get the first attribute of the first child..something which I fail to do! :(</p> <p><strong>UPDATE: What the page sees:</strong></p> <pre><code> Rating: &lt;span class="stars-cap"&gt;&lt;/span&gt; &lt;div class="stars-wrapper1"&gt; &lt;input type="radio" name="newrate" value="1" title="23" /&gt; &lt;input type="radio" name="newrate" value="2" title="23" /&gt; &lt;input type="radio" name="newrate" value="3" title="23" /&gt; &lt;input type="radio" name="newrate" value="4" title="23" /&gt; &lt;input type="radio" name="newrate" value="5" title="23" /&gt; &lt;input type="radio" name="newrate" value="6" title="23" /&gt; &lt;input type="radio" name="newrate" value="7" title="23" /&gt; &lt;input type="radio" name="newrate" value="8" title="23" /&gt; &lt;input type="radio" name="newrate" value="9" title="23" /&gt; &lt;input type="radio" name="newrate" value="10" title="23" /&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload