|
Can a href title show in a specified div?
I want to move mouse on
<a href="www.google.com" title="google" onclick="search.php" target="_blank">google</a>but I do not want the title "google" be showed near the hyperlink. I want show it in a specified "div" layer. the "a href" and "onclick" are occupied. :( Can any one have a good idea? Thanks.
4 Answers
HTML:
<a href="" title="the link" id="myLink">the link</a> <div id="innerWrapper"></div>jquery $(function(){
$("#myLink").mouseover(function(){
var titleString = $("#myLink").attr("title");
$("#innerWrapper").html("<h1>" + titleString + "</h1>");
});});
Here I used the 'mouseover' event as the 'hover' can have 2 parameters, and you only want to do something when the mouse is over the element, not when it goes away, right? But the 'hover' event will still do too, if you want to do something when the mouse goes away. I just did the basics, but you can add more stuffs as you feel appropriate.
Posted: DesignShop 1 of 1 people found this answer helpful. Did you? Yes No
To make the title text appear in a div do this:
HTML: <div id='titleText'></div> <a href='#' title='title text' class='noTitle'>link</a>JS: $(".noTitle").hover(function() {
var thisTitle = $(this).attr("title");
$(this).removeAttr("title");
$("#titleText").html(thisTitle);
},
function() {
var replaceTitle = $("#titleText").html();
$(this).attr("title",replaceText);
$("#titleText").html("");
});Haven't tried it but something like this should work for you.It should get the title on hover, add it to the div and remove title attribute. Then add back the title attribute with the div text when you hover out.
Posted: greentree 2 of 2 people found this answer helpful. Did you? Yes No
ok let's use jquery .hover()
first on hover we show the title of the link in a specific div [example #target] and use the hover callback to make the specific empty again, so look: $("a[title].tip").hover(
function () {
$('div#target').html($(this).attr('title'));
},
function () {
$('div#target').html('');
}
);
and the html
<a class="tip" title="hello i'm jooria, what about you?">test</a> <div id="target"> </div> Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No
I've used a JQUERY plugin called "qTip" before which was very customizeable. the below applies to any anchor with a class of "qtip", and displays the content of title in a styled div.
See tip (no affiliation) but it's one of the better tooltip plugins I've come across imo. $('a[title].qtip').qtip({
style: { name: 'light', tip: true },
position: {
corner: {
target: 'center',
tooltip: 'center'
}
}
})
Posted: Go 1 of 1 people found this answer helpful. Did you? Yes No |
© Advanced Web Core. All rights reserved


Thanks friends. Now I know how to deal with it.
September 21, 2011