[英]How can manually trigger a tooltip over and input box from javascript
I have an ASP.NET web form and on it I have two input boxes. 我有一个ASP.NET Web表单,上面有两个输入框。 When the onkeypress event is triggered in box A, I want a tooltip to appear over box B.
当在框A中触发onkeypress事件时,我希望工具提示出现在框B上方。
I am firing a javascript function from the onkeypress event in box A which should show the tooltip over box B. 我从A框的onkeypress事件中触发了一个javascript函数,该事件应该在B框上显示工具提示。
Should be simple but I can't get the thing to work. 应该很简单,但是我无法正常工作。 Any ideas?
有任何想法吗?
Here is a working Fiddle ... 这是一个工作的小提琴 ...
Html HTML
Input here: <input id="boxA" type="text" onkeypress="PopulatePrice()" />
<br/>
<br/>
Tooltip to appear here: <input id="boxB" title="blah" type="text" />
Javascript 使用Javascript
$('#boxB').tooltip({
$(this).tooltip({
content: 'some stuff',
trigger: 'manual',
placement:'top',
html: true
});
});
function PopulatePrice(){
$('#boxB').tooltip('show');
}
Change your JS as below 如下更改您的JS
$('#boxB').tooltip({
content: 'some stuff',
trigger: 'manual',
placement: 'top',
html: true
});
function PopulatePrice() {
$('#boxB').tooltip('show');
}
Your JS wasn't working because you were getting an Uncaught SyntaxError: Unexpected token this
on the line $(this).tooltip({
. 您的JS无法正常运行,因为您收到了
Uncaught SyntaxError: Unexpected token this
$(this).tooltip({
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.