Focus
window.focus()
e.g.
<html>
<body>
<p>Click the button to open an a new window, and assure that the new window GETS focus (send the new window to the front).</p>
<button onclick="openWin()">Open window</button>
<script>
function openWin()
{
var myWindow = window.open("","","width=200,height=100");
myWindow.document.write("<p>A new window!</p>");
myWindow.focus();
}
</script>
</body>
</html>
2. blur()
$(selector).blur()
e.g
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("input").blur(function(){
alert("This input field has lost its focus.");
});
});
</script>
</head>
<body>
Enter your name: <input type="text">
<p>Write something in the input field, and then click outside the field to lose focus (blur).</p>
</body>
</html>
3. click()
$(selector).click()
e,g
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("p").click(function(){
alert("The paragraph was clicked.");
});
});
</script>
</head>
<body>
<p>Click on this paragraph.</p>
</body>
</html>
4.val()
$(selector).val()
e.g.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("input:text").val("Glenn Quagmire");
});
});
</script>
</head>
<body>
<p>Name: <input type="text" name="user"></p>
<button>Set the value of the input field</button>
</body>
</html>
5.toggle()
$(selector).toggle(speed,easing,callback)
e.g
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button>Toggle between hide() and show()</button>
</body>
</html>
7. WaterMark
$('#inputId').watermark('Required information');
e.g
<html>
<head runat="server">
<title>Sample for Watermark Text Using JavaScript</title>
<script language="javascript" type="text/javascript">
function FuncWaterMark(txtEmail, event) {
var strVal = "Enter EmailID Here";
//Here to check textbox length and event type
if (txtEmail.value.length == 0 & event.type == "blur") {
txtEmail.style.color = "Gray";//setting text color
txtEmail.value = strVal; //setting default text in textbox
}
// Here to check textbox value and event type
if (txtEmail.value == strVal & event.type == "focus") {
txtEmail.style.color = "black";
txtEmail.value = "";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>Email ID:</b>
<asp:TextBox ID="txtEmailID" runat="server" Text="Enter EmailID Here" ForeColor="Gray"
onblur="FuncWaterMark(this, event);" onfocus="FuncWaterMark(this, event);" />
</div>
</form>
</body>
</html>