実行時にいくつかのボックスを生成します。すべてのボックスに「空」というテキストが含まれているかどうかを確認したい場合、ユーザーは続行できません。ただし、1 つのボックスでも (Empty ではなく) box の正しい値が含まれている場合、ユーザーは続行できるはずです。
以下のコードを見つけてください:
HTML
<div>
<div class="bin-area empty floatLeft" style="width:242px; height:130px; ">
<label for="9">
<div class="bin" data-binid="0" data-cols="0" data-rows="0">
<div class="number">S9</div>
<input class="floatLeft styled" id="9" name="checkbox9" type="checkbox" />
<label for="9"><span class="floatLeft marginLeft40">Empty</span>
</label>
<div class="type"></div>
<div class="description">Storage</div>
</div>
</label>
</div>
<div class="bin-area empty floatLeft" style="width:242px; height:130px; ">
<label for="9">
<div class="bin" data-binid="0" data-cols="0" data-rows="0">
<div class="number">S9</div>
<input class="floatLeft styled" id="9" name="checkbox9" type="checkbox" />
<label for="9"><span class="floatLeft marginLeft40">Empty</span>
</label>
<div class="type"></div>
<div class="description">Storage</div>
</div>
</label>
</div>
<div class="bin-area" style=" width:242px; height:130px; ">
<label for="8">
<div class="bin" data-binid="5" data-cols="9" data-rows="5">
<div class="number">S8</div>
<input class="floatLeft styled" id="8" name="checkbox8" type="checkbox" />
<div class="type">9x5 Storage Bin</div>
<div class="description">Est. Capacity: 121 pkgs</div>
</div>
</label>
</div>
</div>
<div style="clear:both"></div>
<div role="button" style="margin-top:20px">
<input type="button" id="stepAutomap" value="Automap" class="active" />
<input type="button" id="stepAutomapBack" value="Back" class="active marginLeft50" />
<input type="button" id="stepAutomapConfirm" value="Confirm & Proceed" class="marginLeft10" />
</div>
これは私の HTML 構造です...既存の投稿のいくつかを検索して、jQuery を使用していくつかの IF ロジックを作成してみました:
私はこのオプションを試しました:
$(document).ready(function () {
$('.bin-area').each(function () {
if ($(this).text() == 'Empty') {
alert("Empty");
}
});
});
そして、このオプション:
$(document).ready(function () {
if ($("span.floatLeft").contains("Empty")) {
alert("Empty");
}
});
しかし、何もうまくいきませんでした!
参照または試してみるフィドルも作成しました。
フィドルを参照してください: http://jsfiddle.net/aasthatuteja/xJtAV/
他に情報が必要な場合はお知らせください。
提案してください!