01.
<html>
02.
<head>
03.
<title>ThaiCreate.Com jQuery Tutorials</title>
04.
<script type=
"text/javascript"
src=
"jquery-1.6.4.js"
></script>
05.
<script type=
"text/javascript"
>
06.
$(document).ready(
function
(){
07.
08.
$(
"#old"
).click(
function
(){
09.
$(
"input"
).trigger(
"focus"
);
10.
});
11.
$(
"#new"
).click(
function
(){
12.
$(
"input"
).triggerHandler(
"focus"
);
13.
});
14.
$(
"input"
).focus(
function
(){
15.
$(
"<span>Focused!</span>"
).appendTo(
"body"
).fadeOut(1000);
16.
});
17.
18.
});
19.
</script>
20.
</head>
21.
<body>
22.
23.
<button id=
"old"
>.trigger(
"focus"
)</button>
24.
<button id=
"new"
>.triggerHandler(
"focus"
)</button><br/><br/>
25.
26.
<input type=
"text"
value=
"To Be Focused"
/>
27.
28.
</body>
29.
</html>