关于JQUERY的问题,不能得到值,求解!
<form action='<?php echo url('default/diary')?>' method='post'>
<div id='cmset'>
<p><span class='marginleft'>标题:</span><span><input class='inputsize' type='text' name='title'><font color='red'>(*)</font></span><span class='titlerror'></span></p>
<p><span class='marginleft'>昵称:</span><span><input class='inputsize' type='text' name='nickname'><font color='red'>(*)</font></span><span class='nickerror'></span></p>
<p><span class='marginleft'>邮箱:</span><span><input class='inputsize' type='text' name='email'><font color='red'>(*)</font></span><span class='emailerror'></span></p>
<p><span>个人主页:</span><span><input class='inputsize' type='text' name='weburl'></span></p>
<p><span>留言内容:</span><textarea rows='4' cols='26' name='content' style="margin-left: 5px; vertical-align: text-top;"></textarea><font color='red'>(*)</font><span class='conerror'></span></p>
<p><span style='margin-left: 55px;'><input type='submit' value='提交'></span>
</div>
</form>
<div class='commentlist'>
</div>
<script type='text/javascript'>
$(document).ready(function(){
$title = $(":input[name='title']").val();
$nickname = $(":input[name='nickname']").val();
$email = $(":input[name='email']").val();
$content = $(":input[name='content']").val();
$(":input[name='title']").blur(function(){
if($title==''){
alert($title); ------------------------------------------------------------------->这里出现的是空值
$('.titlerror').html("<font color='red'>标题不能为空</font>");
}else{
$('.titlerror').html('');
}
});
$("input[name='nickname']").blur(function(){
if($nickname==''){
$('.nickerror').html("<font color='red'>名字不能为空</font>");
}else{
$('.nickerror').html("");
}
});
$("input[name='email']").blur(function(){
if($email==''){
$('.emailerror').html("<font color='red'>邮箱不能为空</font>");
}else{
$('.emailerror').html("");
}
});
$("input[name='content']").blur(function(){
if($content==''){
$('.conerror').html("<font color='red'>内容不能为空</font>");
}else{
$('.conerror').html("");
}
});
});
</script>
我好多方法都试过了,就是得不到文本框里面的值。。。。怎么回事?