facebook - Setting inline URL with Jquery -
i using following code show social icons on hover: can see site here: http://vitaminjdesign.com/adrian/
$('a').live('mouseover mouseout', function(event) { if (event.type == 'mouseover') { $('<a href="http://www.facebook.com/sharer.php?u=(this)" target="blank"><img src="images/facebook.gif" class="facebook" alt="facebook"></a>').appendto(this).fadein(500); $('<a href="#"><img src="images/twitter.gif" class="twitter" alt="twitter"></a>').appendto(this).fadein(500); } else { $('a').find('.facebook,.twitter').stop(true, true).fadeout(500); } });
the problem having within facebook url see (this). want dynamically add in url of link associated current a
being hovered. basically, want add in url of element being hovered on (this) area of url. anyone?
a little nicer way (in opinion) create elements use properties object argument.
also, assume want load new elements once, fade them thereafter.
$('.rssrow').live('mouseenter mouseleave', function(event) { var twitface = $(this).find('.facebook,.twitter'); if (event.type == 'mouseover') { if( twitface.length ) { twitface.fadein(500); } else { loadtwitface.call(this); } } else { twitface.stop(true, true).fadeout(500); } }); function loadtwitface() { $('<a>', { href:'http://www.facebook.com/sharer.php?u="' + $(this).find('a').attr('href') + '"', target:"blank"}) .append($('<img>',{ src:'images/facebook.gif', classname:'facebook', alt:'facebook'})) .appendto(this) .fadein(500); }
Comments
Post a Comment