Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery水印插件有问题_Javascript_Jquery_Html - Fatal编程技术网

Javascript jquery水印插件有问题

Javascript jquery水印插件有问题,javascript,jquery,html,Javascript,Jquery,Html,我试图在我的代码中实现这一点,但我不知道是什么问题。我搜索了很多,但是我没有发现代码中的问题在哪里。先谢谢你 <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js" /> <script type="text/javascript" src="jquery.watermark.js" /> </head>

我试图在我的代码中实现这一点,但我不知道是什么问题。我搜索了很多,但是我没有发现代码中的问题在哪里。先谢谢你

<html>

<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js" />
<script type="text/javascript" src="jquery.watermark.js" />
</head>

<body>

<input type="text" width="300px" id="input">

<script type="text/javascript">
$("#input").watermark("Heee");                              
</script>
</body>

</html>

$(“#输入”)。水印(“Heee”);
更新:

我已编辑了代码,但仍然得到以下结果:

我编辑的代码:

<html>


<body>

<input type="text" width="300px" id="input">

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js" />
<script type="text/javascript" src="jquery.watermark.js" />

<script type="text/javascript">

$("#input").watermark("Heee");                              

</script>
</body>

</html>

$(“#输入”)。水印(“Heee”);

确保始终将jQuery代码包装在文档就绪函数中,如下所示

$(document).ready(function() {
   $("#input").watermark("Heee");                              
});

嗨,我试过你的代码,但我不会工作,我添加了头标签,并使用就绪功能,现在工作得很好。我希望有帮助。问候

问候

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="jquery.watermark.min.js"></script>
</head>

<script type="text/javascript">

$(document).ready(function() {
    $('#inputId').watermark('Required information');
});
</script>

<body>

<input type="text" width="300px" id="inputId">


</body>

</html>

$(文档).ready(函数(){
$('#inputId')。水印(“所需信息”);
});

Try
$(函数(){$(“#输入”).watermark(“Heee”);})@RUJordan不需要这样做。脚本位于正文的末尾。检查控制台是否有错误。jquery.watermark.js文件在哪里?与html相同的文件夹?不同的文件夹?@War10ck我的控制台是什么?你能提供更多的信息吗?大多数现代浏览器都有一个开发人员控制台来帮助你调试你的站点/脚本以及许多其他功能。通常,可以在浏览器菜单中找到console/developer工具选项(可能在“帮助”或“选项”下)。在大多数浏览器中,按
也会打开控制台。这应该不是必需的。这提供的唯一优点是它可以保证页面上的初始元素已经呈现。通过将脚本放在页面主体上,它可以完成相同的任务。初始元素将在到达脚本标记之前加载/呈现。Op不需要在文档就绪处理程序中包装此代码