I am trying to change the title url of a b开发者_如何转开发log post to an external link when using squarespace? I believe this is possible but I don't know the proper code. Any help would be greatly appreciated.
firstly lets create new filter for external links
$.extend($.expr[':'], {
/**
* Filter for External links
*
* @param element we'll need only DOM Element
*/
external: function(element) {
// is it link?
if (element.tagName.toUpperCase() != 'A') return false;
// is there href?..
if (element.getAttribute('href')) {
// cut off unnecessary
if ((element.getAttribute('href').indexOf('/') === 0) // internal link
|| (element.getAttribute('href').indexOf('#') === 0) // hash
|| (element.getAttribute('href').indexOf(window.location.hostname) === 7) // http://...
|| (element.getAttribute('href').indexOf(window.location.hostname) === 8) // https://...
) {
return false;
} else {
// ya, we've found correct links
return true;
}
} else {
return false;
}
}
});
then....
$function({
/* All external links */
$('a:external').each(function(i,e){
e.attr('title', 'Your Title for External Link :) ');
});
});
精彩评论