jQuery Mobile Textinput clearBtnText 选项
jQuery Mobile是一个基于HTML-5的用户界面系统,用于设计手机、标签和台式机的响应式和可访问的网站。它是基于jQuery的。
在这篇文章中,我们将使用jQuery Mobile Textinput clearBtnText选项来设置当悬停在Textinput Widget的clear按钮上时我们将看到的文本。对于这个工作,Textinput clearBtn选项应该被设置为true。clearBtnText选项接受一个String。
语法:
用clearBtnText选项初始化Textinput:
$( ".selector" ).textinput({
clearBtnText: "Your Text Here"
});
- 在初始化后获得clearBtnText选项。
var clearBtnText = $( ".selector" )
.textinput( "option", "clearBtnText" );
- 在初始化后设置clearBtnText选项。
$( ".selector" ).textinput( "option",
"clearBtnText", "Your Text Here" );
CDN 链接:
<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-2.1.3.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js”></script>
例子:在下面的例子中,我们将设置clearBtn选项为true,clearBtnText选项为”Clear The Name”。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible"
content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Popup - reposition method</title>
<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-2.1.3.js">
</script>
<script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js">
</script>
<script>
(document).ready(function () {
( "#GFG" ).textinput({
clearBtn: true,
clearBtnText: "Clear The Name"
});
});
</script>
<style>
.ui-input-text{
width: 400px;
}
</style>
</head>
<body>
<div data-role="page">
<center>
<h2 style="color: green">GeeksforGeeks</h2>
<h3>jQuery Mobile TextInput clearBtnText option</h3>
<br>
<input
id="GFG"
type="text"
name="name"
autocomplete="off"
placeholder="Enter Your Name Here."
/>
</center>
</div>
</body>
</html>
输出:

极客教程