Olaf Bosch schrieb:
> Olaf Bosch schrieb:
>
>> Errors are, all Links are find. $("#text a").favicon(); is the Selector.
>
> Oh, i stupid, i close not the DIV, dammit :)
>
That's not the problem but inside the each loop "this" is a DOM element
and not a jQuery object, thus this.append(cue) won't work.
It has to be: jQuery(this).append(cue)
Also, if you intend to make that plugin chainable (jQuery.fn.favicon)
you have to use:
return this.each(...);
And maybe you don't need to use all the regular expressions to parse the
domain. There are properties ready to use:
this.hostname would give you "www.google.com"
All in all, try this:
jQuery.fn.favicon = function () {
return this.each(function() {
var hoststring = /^http:/i;
var hrefvalue = this.getAttribute("href");
if (hrefvalue.search(hoststring) != -1) {
var domain = this.hostname;
var cuesrc = "http://"+domain+"/favicon.ico";
var cue = "<img class=\"favicon\" src=\""+cuesrc+"\" alt=\"\" />";
jQuery(this).append(cue);
}
});
};
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/