Description
HTML5 placeholder feature made easy with this simple plugin. Just specify the "input" and the placeholder text and you are good to go. Nothing fancy or complicated, just a simple plugin.
Usage
-
Add "jquery" before "
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script></head>
" tag. -
Download jquery-placeholder.js and add it in your html file before "
<script type="text/javascript" src="/path/to/jquery-placeholder.js"></script></head>
" tag. -
Fire the plugin before "
<script type="text/javascript"> $('#search').placeHolder({ 'text': 'Your Placeholder Text' }); </script></body>
" tag. -
That's all!
Options
1) Placeholder Text:
"text": "Some Text"
2) Normal Text Color:
"active": "#000"
3) Placeholder Text Color:
"placeholder": "#333"
4) Autofocus:
"autofocus": true
Example
<html>
<head>
<title>Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery-placeholder.js"></script>
</head>
<body>
<form>
<input type="text" id="something" name="something" />
</form>
<script type="text/javascript">
$("#something").placeHolder({
"text" : "This is the placeholder text",
"active" : "#000",
"placeholder" : "#333"
});
</script>
</body>
</html>