jQuery Mobile Textinput create事件
jQuery Mobile是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。
在这篇文章中,我们将使用jQuery Mobile Textinput创建事件。这个事件是在Textinput widget被创建时触发的。
语法:
初始化Textinput create事件。
$( ".selector" ).textinput({
create: function( event, ui ) {}
});
- 为textinputcreate事件绑定一个事件监听器。
$( ".selector" ).on( "textinputcreate", function( event, ui ) {} );
参数:它接受一个有两个参数的回调函数。
- event。它接受事件类型值。
- ui。它接受对象类型的值。ui对象可以是空的,但为了与其他事件保持一致而使用。
CDN链接:首先,添加你的项目需要的jQuery Mobile脚本。
<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css”>
<script src=”https://code.jquery.com/jquery-1.10.2.min.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>
例子:这个例子描述了jQuery Mobile Textinput create事件。
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src=
"https://code.jquery.com/jquery-1.10.2.min.js">
</script>
<script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
</script>
</head>
<body>
<center>
<div data-role="page">
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h3>jQuery Mobile Textinput
create Event</h3>
<div id="log"></div>
<div data-role="header">
</div>
<div role="main" class="ui-content"
style="width: 50%;">
<label for="GFG">Enter Text:</label>
<textarea name="Geeks" id="GFG"></textarea>
</div>
</div>
</center>
<script>
(document).ready(function () {
("#GFG").textinput({
create: function (event, ui) { }
});
("#GFG").on("textinputcreate",
function (event, ui) { });
("#log").html(
'Textinput widget has been created.'
);
});
</script>
</body>
</html>
输出:
jQuery Mobile Textinput创建事件