使用return返回jquery中多个相同类的警报 [英] alert for multiple same class in jquery with return
本文介绍了使用return返回jquery中多个相同类的警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
i有html代码
Hi
i have html code
<input id="ChildidIntl" class="onlyforage" type="text" name="ageperwise[1]"></input>
<input id="ChildidIntl" class="onlyforage" type="text" name="ageperwise[1]"></input>
<input id="ChildidIntl" class="onlyforage" type="text" name="ageperwise[1]"></input>
<input id="ChildidIntl" class="onlyforage" type="text" name="ageperwise[1]"></input>
我想查看是否任何值空白,显示警告并返回false。
i尝试使用
and i want to check if any value blank , show alert and return false.
i tries using
$(".onlyforage").each(function() {
if ($(this).val() == "") {
alert("Please select age");
}
});
但是没有帮助
请提供
but that did not help
pls provide
推荐答案
( 。onlyforage ).each( function (){
if (
(".onlyforage").each(function() { if (
( this )。val()== ){
alert( 请选择年龄);
}
});
(this).val() == "") { alert("Please select age"); } });
但是没有帮助
请提供
but that did not help
pls provide
它正常工作。
请参阅演示 [< a href =http://jsfiddle.net/taditdash/C99fs/target =_ blanktitle =New Window> ^ ]。
始终为您的元素添加唯一ID。
It is working.
See the Demo[^].
Always have your elements with unique IDs.
这篇关于使用return返回jquery中多个相同类的警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文