Javascript 由于出现错误,无法使用引导触发工具提示
我创建了一个工具提示,以显示Javascript 由于出现错误,无法使用引导触发工具提示,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我创建了一个工具提示,以显示鼠标是否位于被截断的文本上方。 但是我得到了以下错误 错误:无法在初始化之前调用工具提示上的方法;试图调用方法“选项” 我也试着在省略号处于活动状态时调用它,但它不起作用。这里怎么了?怎样才能做到这一切 html: <div> <label class='form-control' data-toggle='tooltip' data-placement='bottom' title='something'>truncated text
鼠标是否位于被截断的文本上方。
但是我得到了以下错误
错误:无法在初始化之前调用工具提示上的方法;试图调用方法“选项”
我也试着在省略号处于活动状态时调用它,但它不起作用。这里怎么了?怎样才能做到这一切
html:
<div>
<label class='form-control' data-toggle='tooltip' data-placement='bottom' title='something'>truncated text</label>
<div>
$(document).on('mouseenter', ".form-control", function () {
var $this = $(this);
if (this.offsetWidth > this.scrollWidth) {
$this.tooltip('options', 'show');
}
});
根据,使用.tooltip('show')
仅与
$this.tooltip('show');
你的代码应该是
$(document).on('mouseenter', ".form-control", function () {
var $this = $(this);
if (this.offsetWidth > this.scrollWidth) {
$this.tooltip('show');
} else {
$this.tooltip('hide');
}
});
片段
$(document).on('mouseenter',“.form control”,函数(){
var$this=$(this);
$this.tooltip('show');
});代码>
截断文本
根据,仅使用.tooltip('show')
类似
$this.tooltip('show');
你的代码应该是
$(document).on('mouseenter', ".form-control", function () {
var $this = $(this);
if (this.offsetWidth > this.scrollWidth) {
$this.tooltip('show');
} else {
$this.tooltip('hide');
}
});
片段
$(document).on('mouseenter',“.form control”,函数(){
var$this=$(this);
$this.tooltip('show');
});代码>
截断文本
请参阅
$(document).on('mouseenter',“.iffytp”,函数(){
var$this=$(this);
if(this.offsetWidth
请参阅
$(document).on('mouseenter',“.iffytp”,函数(){
var$this=$(this);
if(this.offsetWidth
我得到了这个错误:初始化之前无法调用工具提示上的方法;尝试调用方法“show”,如果在元素中添加了数据切换class='tooltip'数据放置class='bottom'title='something'
,则不会导致任何错误。由于选择器data toggle='tooltip'
会在引导工具提示js中自动初始化它,但由于某些原因它不会。Bootstrap.min确实是链接的。我得到了这个错误:在初始化之前不能在工具提示上调用方法;尝试调用方法“show”,如果在元素中添加了数据切换class='tooltip'数据放置class='bottom'title='something'
,则不会导致任何错误。由于选择器data toggle='tooltip'
会在引导工具提示js中自动初始化它,但由于某些原因它不会。Bootstrap.min是绝对链接的。不管省略号是否有效,它都不会进入if statemet内部。如果(this.offsetWidth