[jQuery] New to Jquery : Using it on dynmaically created divs
Hi. At the moment I've creating 2 divs for each record in a database.
One to first give a title for that piece of information and the second
to be a show/hide div that gives furthur information upon clicking a
little arrow. I generate both divs server side on an updatepanel
refresh. I have them showing/hiding at the moment using this
function...
function divShowHide(divID, imgID){ // Hides/Shows the second div and
changes arrow appearance
var divToChange = document.getElementById(divID);
if(divToChange.style.display == "block") {
divToChange.style.display = "none";
document.getElementById(imgID).src = "Images/downarrow.png";
}
else {
divToChange.style.display = "block";
document.getElementById(imgID).src = "Images/uparrow.png";
}
}
I was wandering if I could incorporate Jquery into this function to
make it do the job , or if all the divs have to be created in the head
section with jquery beforehand?? I have tried using the show/hide
commands in the above function using Jquery but they don't seem to
work. Each of my second divs have a unique ID, I just need to know if
it's possible to do it in this way?? All the examples on the site use
pre-defined names for divs but as I do not know the ammount of div
sets before so can't do that. They are all called "div2" + a unique
identifyier.
Any help would be greatly appreciated.
Thanks,
James