简体   繁体   中英

Something wrong with jquery watermark plugin

I'm trying to implement this in my code but I don't know what is the matter. I searched a lot but I could not discover where is the problem in my code. Thank you in advance.

<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>

Update:

I have edited my code and still get this result:

在此处输入图片说明

My edited code:

<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>

Make sure you always wrap your jQuery code around a document ready function, like this...

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

Hi i tried with your code but i wont work, I added the head tag and use the ready function and now works well. I hope it helps. Regards

Regards

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM