[英]Enable jQuery mouseover event
I have some code that displays a message when a link is hovered over. 当链接悬停时,我有一些显示消息的代码。 This is using tooltipster and initially on page load it works fine. 这是使用工具提示器,最初在页面加载时工作正常。 My problem happens when i click a radio button, this in turn changes the text of class tooltipbfile
to what I want but when I click to change the text back, it seems to have lost its hover function. 我的问题发生在我单击单选按钮时,这又将class tooltipbfile
的文本更改为我想要的文本,但是当我单击以将文本更改回时,它似乎失去了其悬停功能。 No tooltip is displayed. 没有显示工具提示。 Do I have to enable mouseenter events somewhere. 我是否必须在某处启用mouseenter事件。 I have looked at code like $(".tooltipbfile").prop('enabled', true);
我看过像$(".tooltipbfile").prop('enabled', true);
but it doesn't make any difference. 但这没有任何区别。
I would appreciate if someone could show me the correct way to re enable mouse events after a click event. 如果有人可以向我展示单击事件后重新启用鼠标事件的正确方法,我将不胜感激。 Thanks 谢谢
UPDATE : As per tooltipster API. 更新 :根据tooltipster API。 $(".tooltipbfile").tooltipster('disable'); $(“。tooltipbfile”)。tooltipster('disable');
jQuery code jQuery代码
$(function() {
$('input:radio').click(function(){
if($(this).val()=='New Intake'){
$("#fileref").hide();
$(".maxbox").show();
$("#INTKAddMoreFileBox").show();
$(".tooltipbfile").text("Help");
}else if($(this).val()=='New Intake Files'){
$("#fileref").show();
$(".maxbox").hide();
$(".tooltipbfile").text("Some text here.").show();
$("#INTKAddMoreFileBox").hide();
$(".tooltipbfile").tooltipster('disable');
}
});
});
Tooltipster code 工具提示代码
Works correctly on page load 在页面加载时正常工作
<script type="text/javascript">
$(document).ready(function() {
$('.tooltipbfile').tooltipster({
theme: 'tooltipster-light',
position: 'right',
animation: 'fade',
fixedWidth: 200,
maxWidth: 290,
content: $('<span>blah blah blah</span>')
});
});
</script>
HTML 的HTML
relevant part 相关部分
<div class="fieldset">
<h1><span>Enter Box(es) Reference</span></h1>
<p>
<a href="#" id="INTKAddMoreFileBox" class="btn btn-info">Add More Boxes</a>
<span class="maxbox" style="margin-left:10px;font-size:10px;color: grey;">( Maximum 8 )</span>
<!--<div class="bxhelp">
You now have the ability to input more than 1 box just by clicking the Add More boxes link. Please only enter 1 box reference per box. You can enter up to a maximum of 8 boxes.
<a href="javascript:void(0)" class="boxhelpcls">Close</a>
</div>-->
<div id="INTKInputsWrapper">
<p>
<input name="box_add[]" type="text" required="required />
<a href="javascript:void(0)" class="removeclass"></a>
<a style="margin-left: 14px;" href="javascript:void(0)" class="tooltipbfile">Help</a>
</p>
</div>
</p>
</div>
<div class="fieldset" id="fileref">
<h1><span>Enter File References</span></h1>
<p>
<a href="javascript:void(0)" id="BFINTKAddMoreFile" class="btn btn-info">Add More Files</a>
<span class="fmaxbox" style="margin-left:10px;font-size:10px;color: grey;">( Maximum 8 )</span>
<!--<div class="fbxhelp">
You now have the ability to input more than 1 file just by clicking the Add More files link. You can enter up to a maximum of 8 files.
<a href="javascript:void(0)" class="fboxhelpcls">Close</a>
</div>-->
<div id="BFINTKInputsWrapper">
<p>
<input name="bfile_add[]" id="bfile_add[]" type="text" required="required" />
<a href="javascript:void(0)" class="removeclass"></a>
<a style="margin-left: 14px;" href="javascript:void(0)" class="fboxhelp">Help</a>
</p>
</div>
</p>
</div>
After clicking the object to turn it back into a tooltipbfile, simply re-call tooltipster() on it, as the program does on document.ready: 单击对象以将其转换回tooltipbfile之后,只需在该对象上重新调用tooltipster()即可,就像程序对document.ready一样:
.tooltipster({
theme: 'tooltipster-light',
position: 'right',
animation: 'fade',
fixedWidth: 200,
maxWidth: 290,
content: $('<span>blah blah blah</span>')
});
I've never used tooltipster, but this should work. 我从未使用过工具提示,但是应该可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.