Jquery 输入框上的水印无效
我用下面的代码放了一个水印,这个位于 但是右下角的文本框没有显示掩码Jquery 输入框上的水印无效,jquery,css,Jquery,Css,我用下面的代码放了一个水印,这个位于 但是右下角的文本框没有显示掩码 <script language="javascript"> $(document).ready(function () { $(":input[data-watermark]").each(function () { $(this).val($(this).attr("data-watermark")); $(this).bind('focus', function
<script language="javascript">
$(document).ready(function () {
$(":input[data-watermark]").each(function () {
$(this).val($(this).attr("data-watermark"));
$(this).bind('focus', function () {
if ($(this).val() == $(this).attr("data-watermark")) $(this).val('');
});
$(this).bind('blur', function () {
if ($(this).val() == '') $(this).val($(this).attr("data-watermark"));
$(this).css('color','#a8a8a8');
});
});
});
</script>
<form onsubmit="setTimeout(function() {location.replace('./emails');},100)" name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post">
<div class="form-subscribe">
<!--<div class="newsletter-lable"><label for="newsletter">Newsletter Sign-up:</label></div>-->
<div class="input-box">
<input type="text" name="ea" title="Sign up for our newsletter" class="input-text required-entry validate-email" data-watermark="Type your email and subscribe"/>
$(文档).ready(函数(){
$(“:输入[数据水印]”)。每个(函数(){
$(this.val($(this.attr(“数据水印”));
$(this.bind('focus',function(){
if($(this.val()==$(this.attr(“数据水印”))$(this.val(“”);
});
$(this.bind('blur',function(){
if($(this.val()='')$(this.val($(this.attr)(“数据水印”);
$(this.css('color','#a8a8a8');
});
});
});
您正在使用jQuery函数,如$
(在结果中使用ready
),尽管您没有包括jQuery。这将产生错误(请使用F12在浏览器控制台中查看):
uncaughttypeerror:对象#没有方法“就绪”
在JavaScript代码之前包含带有
元素的jQuery,如下所示:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
</script>
或者,使用prototype(您已经包括了它).您不是您!是的,但是当我把那一行放进去的时候,菜单就不起作用了。!
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
</script>