Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get an input based on a string inside a div via jquery
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/10329477/if-element-contains-certain-text">If element contains certain text</a> </p> </blockquote> <p>I have this <strong>(updated)</strong> html:</p> <pre><code>&lt;div&gt; &lt;div class="checkBox"&gt; &lt;input type="checkbox" name="toppings" class="NS" value="n" /&gt; &lt;/div&gt; No Sauce &lt;/div&gt; &lt;div&gt; &lt;div class="checkBox"&gt; &lt;input type="checkbox" name="toppings" class="NC" value="x" /&gt; &lt;/div&gt; No Cheese &lt;/div&gt; &lt;div&gt; &lt;div class="checkBox checkBoxSelected"&gt; &lt;input type="checkbox" name="toppings" class="no_submit" checked="checked" value="" /&gt; &lt;/div&gt; Regular Cheese &lt;/div&gt; &lt;div&gt; &lt;div class="checkBox"&gt; &lt;input type="checkbox" name="toppings" class="no_submit" value="" /&gt; &lt;/div&gt; Regular Sauce &lt;/div&gt; </code></pre> <p>How can I (via jquery) get the input type that's inside the div containing the text "Regular Cheese"? </p> <p>I know I can get all checkboxes like this:</p> <pre><code>$("input.no_submit:checkbox") </code></pre> <p>And I understand that if I want to affect the parent div of the item, I could do this:</p> <pre><code>$("input.no_submit:checkbox").parent("div").removeClass("checkBoxSelected"); </code></pre> <p>I can get the actual text like this:</p> <pre><code>​var myText = $("div").text(); </code></pre> <p>But I can't figure out how to combine them so that I can set a var that points to the actual input element inside the nested div which is itself inside a classless div whose text is a specific string.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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