Hi John / jQuery team
Firstly, this is tremendously exciting stuff. I just moved from the heavyweight bulk of Dojo, and am enjoying myself immensely. This is a last resort, as I have looked everywhere in the documentation to try and find a solution to the following, but can't, and the forums aren't really conduisive to quick discussion yet.
I'm trying to create a simple Ajax FAQ type app. I have four <a> links on a page, each assigned a class "open_button" and I want each one to open a corresponding <div> immediately below it. To differentiate between them, I am using the syntax <div id="section0">, <div id="section1"> etc.
I wondered if it was possible to iterate through these <a class="open_button"> elements using:
$("a.open_button").each(function(i){ //code to add a click method });
BUT instead of setting an actual attribute (like the img example in the documentation for "each" -
http://docs.jquery.com/Core#each.28_fn_.29) you set a method, dynamically assigning the target element. So each instance of <a class="open_button"> opens a different <div>.
For a single anchor, the code would be:
$("a.open_button").click(function(){
$("#section0").addClass("open");
$("#section0").slideToggle(1200, function() {
complete(0);
});
return false;
});
BUt obviously I need to dynamically assign 0, 1, 2, 3 to each of the anchors.
Is this possible using "each" or am I barking up the wrong tree?
I will continue to search the docs, as I'm sure you get snowed with questions. At any rate, thanks for a great library... we look forward to developing with it.
Thanks,
Steve Jones