1
這是問題的第二部分:jQuery工具提示彈出窗口重新插入標題值 - 工作是的!
在關閉彈出窗口時,我需要在彈出鏈接被點擊前重新插入title =「」值到原始值。彈出使用標題=「」值,在彈出的顯示,並從原來的標籤去掉它,好像有人懸停在鏈接不是在提示顯示。
的JS
this.contactPreview = function() {
jQuery("a.contact").live('click', function(e){
//store clicked link
var $this = jQuery(this);
//store title
var title = $this.attr('title');
//remove title
$this.attr('title', '');
//tip !== "" ? "<br />" + title : "";
jQuery("body").append("<p id='contact-info'>" + title + "<a id='close-contact' class='close-contact' style='color:red;'>Close</a></p>");
//store reference to anchor and persist title on close-contact anchor
jQuery('#close-contact').data('anchor', $this).data('title', title);
jQuery("#contact-info").css("top", (e.pageY - xOffset) + "px")
.css("left", (e.pageX + yOffset) + "px")
.fadeIn(500);
});
jQuery("#close-contact").live('click', function(){
//store clicked link
var $this = jQuery(this);
//get anchor
var $anchor = $this.data('anchor');
//get title
var title = $this.data('title');
//set anchors title back
$anchor.attr('title', title);
//remove tip
jQuery('#contact-info').remove();
});
};
// Use jQuery() instead of $()for WordPress compatibility with the included prototype js library which uses $()
// http://ipaulpro.com/blog/tutorials/2008/08/jquery-and-wordpress-getting-started/
// See http://chrismeller.com/using-jquery-in-wordpress
jQuery(document).ready(function(){
// Call the function here
contactPreview();
});
的CSS
#contact-info{
position:absolute;
border:1px solid #ccc;
background:#333;
padding:5px;
display:none;
color:#fff;
的HTML
<a class='contact' title='this is what is in the popup'>Display popup</a>
再次
感謝所有;)
Hi和感謝名單,只是一個問題,這樣的:(提示== 「
」 +標題: 「 」?「」 )不工作。提示說沒有定義提示錯誤。 還需要使用,而不是$的jQuery但那不是什麼大不了的 – 2009-08-19 12:48:00
由於得到它的工作的,將張貼工作代碼:) – 2009-08-19 12:53:27
你應該已經離開了原來的問題,並可以加入和你一起去解決一個更新位對於。很高興工作。 – redsquare 2009-08-19 12:57:39