[jQuery] [Newbie] dynamic text loads...
From:
discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com] On
Behalf Of Birgit Pauli-Haack
Subject: [jQuery] [Newbie] dynamic text loads...
Is there a way to get this solved dynamically?
Birgit
-----
UNTESTED, but something like this should work...
$("a[@id]").hover(function () {
$("#boxtext").html(texts[this.id]);
});
As long as the id of the link is the same as the key in the texts array
the desired text should pop up.
I'll explain in detail what's happening just to be safe. Pardon me if
this is already understood.
First, we snag all the links that have an id, by using the [@attribute]
selector, which checks for the existence of an ID. Each element found
is added to the jQuery 'bucket'.
Next, each of the elements found have a hover event attached to it.
When using a jQuery function like .hover() 'this' refers to the element
being manipulated. 'this' is a normal HTML element, with all attributes
intact. We simply pull the id (this.id) and use that as the key for the
texts array, and use .html() to feed this content to #boxtext.
Someone might explain this better than I but you should have a clearer
idea of what's going on now.
For more info on the various selectors jQuery supports, check out :
http://jquery.com/docs/Base/Expression/
-ALEX
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/