我到处找了看,有没有办法强制显示tooltip,不是用事件,而是用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.
}
});
});
最佳答案
要触发工具提示显示,您需要使用工具提示的 'show'
选项。这是一个例子。
$('#element').tooltip('show')
将 #element
替换为您自己的选择器。
要使用 Jquery 本身添加标题,您可以这样做
$('#element').tooltip({title:"测试标题"})
关于javascript - 使用javascript强制显示 Bootstrap 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36293133/