好吧我有一個jQuery對話框,它有一個表單,我在我的智慧結束試圖弄清楚...讓我看看我是否可以口頭說明我正在嘗試做什麼。 。jquery:如果ul是空的
我有3個文本框。 #apInterest
,#apPayment
和#apPrincipal
。什麼我試圖做
基本的英語術語:
在#apInterest
如果.val
比99.99觸發錯誤更大小於0或者KEYUP ..否則檢查ul#mylist
如果有任何li
,如果不是.hide
on keyup #apPayment
if .val
is less than 0觸發錯誤否則檢查列表li
如果不是,則隱藏。
#apPrincipal
是同樣的事情完全一樣#apPayment
我有什麼正確的這一刻
$('#apInterest').live("keyup", function(e) {
var parent = $('.inter').parents("ul:first");
if ($('#apInterest').val() < 0 || $('#apInterest').val() > 99.99) {
$('.inter').remove();
$('#mylist').append('<li class="inter">Interest Rate cannot be below 0 or above 99.99</li>');
$('#popuperrors').show();
$(this).addClass('error');
} else {
$(this).removeClass('error');
$('.inter').remove();
alert(parent.children().text);
if (parent.children().length == 0){
$('#popuperrors').hide();
}
}
});
雖然我也曾嘗試
if ($("#mylist :not(:contains(li))")){
$('#popuperrors').hide();
}
我有類似的這種對所有功能3文本框,但沒有我所嘗試似乎工作..任何想法如何完成此
可能重複[jQuery的,如果DIV ID有孩子(http://stackoverflow.com/questions/1526873/jquery-if-div-id-has-children) –