jQuery错误:ReferenceError:未定义completedInputs
我目前正在编写一些jQuery,它将检查某个div中的所有input和select元素是否都有一个值集(非null),然后一旦它们都有一个值,它将显示一个next按钮,该按钮将滑入表单的下一部分 这是我的标记:jQuery错误:ReferenceError:未定义completedInputs,jquery,Jquery,我目前正在编写一些jQuery,它将检查某个div中的所有input和select元素是否都有一个值集(非null),然后一旦它们都有一个值,它将显示一个next按钮,该按钮将滑入表单的下一部分 这是我的标记: <div id="signupFormInner"> <form action="/" method="post" id="form1"> <div id="slide1"> <lab
<div id="signupFormInner">
<form action="/" method="post" id="form1">
<div id="slide1">
<label for="title">Title:</label>
<select name="title" id="title">
<option value="">-- Please select --</option>
<?php foreach($this->titles as $title) { ?>
<option value="<?php echo $title; ?>"><?php echo $title; ?></option>
<?php } ?>
</select>
<label for="firstname">First Name:</label><input type="text" name="firstname" id="firstname" />
<label for="lastname">Last Name:</label><input type="text" name="lastname" id="lastname" />
<label for="email">Email Address:</label><input type="email" name="email" id="email" /><label for="email">Confirm Email Address:</label><input type="email" id="email_confirm" />
</div>
<div id="slide2">
content in here
</div>
<div id="slide3">
content in here
</div>
</form>
</div>
我在这里试图做的是,当用户更改表单的一个元素时,jQuery将检查该表单div中的所有其他元素是否也有值,如果是,就像前面所说的,它将允许用户按下按钮以滑入包含表单更多元素的下一个div
如您所见,我正在将一个名为completedInputs的变量设置为true或false,这取决于该div中的所有其他元素是否已完成,但我不断收到一个错误,即:
ReferenceError: completedInputs is not defined
[Break On This Error]
alert(completedInputs);
我似乎无法解决这个问题,因为我定义了变量,无论它是真是假,所以不确定为什么它说它是未定义的
有人能看出我哪里出了问题吗?
谢谢范围问题-在
之外定义完成的输入
。each()
ReferenceError: completedInputs is not defined
[Break On This Error]
alert(completedInputs);
var completedInputs;
jQuery("#" + parentDivId + " input, #" + parentDivId + " select").each(function(i2, v2) {
if(jQuery(v2).attr('value') == "") {
completedInputs = false;
} else {
completedInputs = true;
}
});
alert(completedInputs);