Jquery 工具提示插件
我对这个 jquery 插件非常陌生,我开始研究这个工具提示插件:
jQuery(function ($) {
$.fn.simpleMessageTtip = function (options) {
var settings = {
'messageTxt': 'The notification frequency has been updated',
};
if (options) {
$.extend(settings, options);
}
var getTooltip = function () {
var tTip =
'<div class="simple-message-tooltip">' +
'<div class="message clearfix">' +
'</div>' +
'<div class="bubble-pointer-bottom"></div>' +
'</div>';
return tTip;
};
$("body").prepend(getTooltip());
$(this).each(function () {
var $this = $(this); //the caller of the ttip
var tip = $('.simple-message-tooltip');
var tipInner = $('.simple-message-tooltip .message');
var setTip = function (top, left) {
var topOffset = tip.height();
var xTip = (left - 50) + "px";
var yTip = (top - topOffset - 40) + "px";
tip.css({ 'top': yTip, 'left': xTip });
};
$this.click(function(){
var offset = $(this).offset(); //Offset returns an object containing the properties top and left.
var tLeft = offset.left;
var tTop = offset.top;
tipInner.html(messageTxt);
setTip(tTop, tLeft);
},
function () {
tip.fadeIn("fast");
setTimeout(function(){
tip.fadeOut("fast");
}, 1000);
}
);
});
};
} (jQuery));
目前可以工作(你可以说哈哈),但有一些问题。也许你能帮我找出原因?
这是当您单击单选按钮时出现的工具提示。
我的第一个问题是,我希望里面的文本是一个可以稍后更改的设置,以便使插件更具可扩展性...但是目前插件没有给我带来文本=(
另外,它不是 之上,
如果您能帮助我,我将非常优雅!
将工具提示准确地放在用户选择的单选按钮 rel="nofollow">http://jsfiddle.net/Vrfsx/9/
提前感谢大家!! =) 橙汁。-
I am very newby as doing this jquery plugins and I started working on this tooltip plugin:
jQuery(function ($) {
$.fn.simpleMessageTtip = function (options) {
var settings = {
'messageTxt': 'The notification frequency has been updated',
};
if (options) {
$.extend(settings, options);
}
var getTooltip = function () {
var tTip =
'<div class="simple-message-tooltip">' +
'<div class="message clearfix">' +
'</div>' +
'<div class="bubble-pointer-bottom"></div>' +
'</div>';
return tTip;
};
$("body").prepend(getTooltip());
$(this).each(function () {
var $this = $(this); //the caller of the ttip
var tip = $('.simple-message-tooltip');
var tipInner = $('.simple-message-tooltip .message');
var setTip = function (top, left) {
var topOffset = tip.height();
var xTip = (left - 50) + "px";
var yTip = (top - topOffset - 40) + "px";
tip.css({ 'top': yTip, 'left': xTip });
};
$this.click(function(){
var offset = $(this).offset(); //Offset returns an object containing the properties top and left.
var tLeft = offset.left;
var tTop = offset.top;
tipInner.html(messageTxt);
setTip(tTop, tLeft);
},
function () {
tip.fadeIn("fast");
setTimeout(function(){
tip.fadeOut("fast");
}, 1000);
}
);
});
};
} (jQuery));
By the moment is sort of working (you could say lol) but with some problems. Maybe you please help me to find out why?
This is a tooltip that appears when you click on a radiobutton.
My first problem is that I would like the text inside to be a SETTING that can be changed later in order to make the plugin more maleable...But by the moment the plugin is not bringing me the text =(
Also, It is not bringing the tooltip EXACTLY on top of the radiobutton that the user selects.
If you could help me I will be greatly gracefully!!!
This is the fiddle: http://jsfiddle.net/Vrfsx/9/
THANKS IN ADVANCE ALL!! =)
OrangeJuice.-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你已经很接近让它发挥作用了。您唯一需要更改的是您的点击处理程序。以下内容:
不正确;第一个函数永远不会被执行(由于
click
的重载,有两个参数,最后一个是事件处理程序)现有。要纠正此问题,您所需要做的就是合并两个函数:更新的代码: http:// /jsfiddle.net/Bky7F/
You're pretty close to having it working. The only thing you need to change is your
click
handler. The following:Is incorrect; the first function will never be executed (due to an overload of
click
with two arguments, the last being an event handler) existing. All you should have to do to correct this is merge the two functions:Updated code: http://jsfiddle.net/Bky7F/