Oma*_*rio 3 javascript jquery twitter-bootstrap
我一直在寻找各地,有没有办法强制显示工具提示,不使用事件,而是使用js代码,因为我们都知道数字输入和粘贴漏洞的缺陷.
<script type="text/javascript">
var previous;
//Buy Button JS code
$(function () {
$("#searchform").bind('submit', function () {
var str = $('#search-form').val();
if (str.match(/^[0-9]*$/)) {
//Great, continue executing the script.
}
else
{
//Force show a tooltip asking the user to numerically type the text.
}
});
});
Run Code Online (Sandbox Code Playgroud)
要触发显示工具提示,您需要使用'show'
工具提示选项.这是一个例子.
$('#element').tooltip('show')
替换#element
为您自己的选择器.
要使用Jquery本身添加标题,您可以执行此操作
$('#element').tooltip({title:"test title"})