gpt4 book ai didi

jQuery .blur 不起作用

转载 作者:行者123 更新时间:2023-11-28 04:00:21 26 4
gpt4 key购买 nike

我有 3 个 .blur,但出于某种原因只有第一个有效。这是 jquery 代码:

<script type='text/javascript'>
$(document).ready(function() {
$("#user_name").blur(function() {
if ($(this).val().length > 4) {
$("#usernamecheckbox").html("<img src='images/checkmark.png' alt='' />");
} else {
$("#usernamecheckbox").html("<img src='images/xmark.png' alt='' />");
}
});
$("#pass").blur(function() {
if ($(this).val().length < 4) {
$("#passcheckbox").html("<img src='images/xmark.png' alt='' />");
}
});
$("#confirmpass").blur(function() {
if ($(this).val() != $("#pass").val()){
$("#passcheckbox").html("<img src='images/xmark.png' alt='' />");
} else {
$("#passcheckbox").html("<img src='images/checkmark.png' alt='' />");
}
});
});
</script>

这是表格:

<form  enctype="multipart/form-data" method='post' action='reg.php'>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<p>Username <span class='sub'>must be atleast 4 characters</span></p>
<input type='text' name='user_name' id='user_name' /> <div id='usernamecheckbox' class='checkbox'></div><br />
<p>Password <span class='sub'>must be atleast 4 characters</span></p>
<input type='password' id='pass' name='pass' /> &nbsp; <input type='password' name='confirm' id='confirmpass' /> <div id='passwordcheckbox' class='checkbox'></div><br />
<p>E-mail <span class='sub'>must be a valid E-mail address</span></p>
<input type='text' name='email' id='email' size='40' /> <div id='emailcheckbox' class='checkbox'></div><br />
<p>Avatar</p>
<input type='file' name='avatar' /><br /><br />
<?php
require_once('recaptchalib.php');
$publickey = "6LdLYwcAAAAAAEeupJKr_IBviIq-xHX5W98IacgZ"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
<br />
<input type='submit' value='Submit'>
</form>

最佳答案

在假设 blur() 不起作用之前,您应该使用一些简单的代码对其进行测试,例如:

$("#pass").blur(function() {
alert('#pass blur triggered');
});

我认为问题在于您正在寻找 $("#passcheckbox")。我在您的 HTML 中没有看到任何带有 id="passcheckbox" 的内容。看起来你的意思是 $("#passwordcheckbox")

关于jQuery .blur 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1167855/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com