Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery: check if all <DIV> or <Span> contains a specific text
    primarykey
    data
    text
    <p>I generate few boxes at runtime, where I want to confirm if all the boxes contains text "Empty", then the user should not be able to proceed. But if even a single Box contains the correct value of box (instead of Empty), then user should be able to proceed.</p> <p>Please find me code below:</p> <p><strong>HTML</strong></p> <pre><code>&lt;div&gt; &lt;div class="bin-area empty floatLeft" style="width:242px; height:130px; "&gt; &lt;label for="9"&gt; &lt;div class="bin" data-binid="0" data-cols="0" data-rows="0"&gt; &lt;div class="number"&gt;S9&lt;/div&gt; &lt;input class="floatLeft styled" id="9" name="checkbox9" type="checkbox" /&gt; &lt;label for="9"&gt;&lt;span class="floatLeft marginLeft40"&gt;Empty&lt;/span&gt; &lt;/label&gt; &lt;div class="type"&gt;&lt;/div&gt; &lt;div class="description"&gt;Storage&lt;/div&gt; &lt;/div&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class="bin-area empty floatLeft" style="width:242px; height:130px; "&gt; &lt;label for="9"&gt; &lt;div class="bin" data-binid="0" data-cols="0" data-rows="0"&gt; &lt;div class="number"&gt;S9&lt;/div&gt; &lt;input class="floatLeft styled" id="9" name="checkbox9" type="checkbox" /&gt; &lt;label for="9"&gt;&lt;span class="floatLeft marginLeft40"&gt;Empty&lt;/span&gt; &lt;/label&gt; &lt;div class="type"&gt;&lt;/div&gt; &lt;div class="description"&gt;Storage&lt;/div&gt; &lt;/div&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class="bin-area" style=" width:242px; height:130px; "&gt; &lt;label for="8"&gt; &lt;div class="bin" data-binid="5" data-cols="9" data-rows="5"&gt; &lt;div class="number"&gt;S8&lt;/div&gt; &lt;input class="floatLeft styled" id="8" name="checkbox8" type="checkbox" /&gt; &lt;div class="type"&gt;9x5 Storage Bin&lt;/div&gt; &lt;div class="description"&gt;Est. Capacity: 121 pkgs&lt;/div&gt; &lt;/div&gt; &lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;div role="button" style="margin-top:20px"&gt; &lt;input type="button" id="stepAutomap" value="Automap" class="active" /&gt; &lt;input type="button" id="stepAutomapBack" value="Back" class="active marginLeft50" /&gt; &lt;input type="button" id="stepAutomapConfirm" value="Confirm &amp;amp; Proceed" class="marginLeft10" /&gt; &lt;/div&gt; </code></pre> <p>This is my HTML structure... by searching some of the existing posts, I tried creating some IF logic using JQuery :</p> <p>I tried this option:</p> <pre><code>$(document).ready(function () { $('.bin-area').each(function () { if ($(this).text() == 'Empty') { alert("Empty"); } }); }); </code></pre> <p>And this option:</p> <pre><code>$(document).ready(function () { if ($("span.floatLeft").contains("Empty")) { alert("Empty"); } }); </code></pre> <p>But nothing worked!</p> <p>I have also created a fiddle to refer or try!</p> <p>Please refer the fiddle: <strong><a href="http://jsfiddle.net/aasthatuteja/xJtAV/" rel="nofollow">http://jsfiddle.net/aasthatuteja/xJtAV/</a></strong></p> <p>Let me know if you need any other info.</p> <p>Please suggest!</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.
    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