我有一个函数将返回真或假
$.fn.valForm = function(){
if($(this).val().length < $(this).attr("minLength"))
{
alert("false");
}
else
{
alert("true");
}
};
执行multiselector (4)
$("#txtFirst, #txtLast, #txtNick, #txtEmail").valForm();
it result 1 time alert only
I need it result time alert like this
$("#txtFirst").valForm();
$("#txtLast").valForm();
$("#txtNick").valForm();
$("#txtEmail").valForm();
怎么做更简单?
你的插件不是用来处理这个的。
当你做插件时,总是添加return this.each
,即:
$.fn.valForm = function() {
return this.each(function() {
if($(this).val().length < $(this).attr("minLength"))
{
alert("false");
}
else
{
alert("true");
}
});
};