jQWidgets jqxWindow focus()方法
jQWidgets 用于在应用程序中输入数据或查看信息。
focus()方法被用来聚焦指定的窗口。这个方法不需要任何参数。
语法:
$('#jqxWindow').jqxWindow('focus');
Linked Files: 从给定的链接中下载https://www.jqwidgets.com/download/。在HTML文件中,找到下载文件夹中的脚本文件。
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.summer.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.10.2.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxwindow.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
示例:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"
href="jqwidgets/styles/jqx.base.css"
type="text/css" />
<link rel="stylesheet"
href="jqwidgets/styles/jqx.summer.css"
type="text/css" />
<script type="text/javascript"
src="scripts/jquery-1.10.2.min.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxcore.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxwindow.js">
</script>
<script type="text/javascript"
src="jqwidgets/jqxbuttons.js">
</script>
<script type="text/javascript">
(document).ready(function () {
('#jqxwindow').jqxWindow({
theme: 'energyblue'
});
("#jqxbutton").jqxButton({
theme: 'energyblue',
width: 250,
height: 30
});
('#jqxbutton').click(function () {
$("#jqxwindow").jqxWindow('focus')
});
});
</script>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h3>
jQWidgets jqxWindow focus() Method
</h3>
<input type="button"
id="jqxbutton"
value="Invoke the focus() method"/>
<div id='content'>
<div id='jqxwindow'>
<div> Header</div>
<div>
<div>GeeksforGeeks</div>
</div>
</div>
</div>
</center>
</body>
</html>
输出:
NOTE: 在上面的输出中,点击 “调用focus()方法 “按钮后,指定的窗口被聚焦,然后通过点击键盘上的向上、向下、向左和向右的箭头按钮就可以进行上述移动。