javascript - Toggle Open/Close JS function -
i've never posted here before, , i'm hoping can me. have js function on click toggle display , hiding paragraph. however, need nest them upon 1 another. in other words:
1) text here //click open
2)this text opens upon click //click open 3)this text opens upon click.
they way have written now, clicking 1 opens 2 up, clicking 2 closes everything. i'm learning js now, i'm best it, i'm hoping pros here can me. here's function looks http://pastebin.com/zuzp1puj got ideas?
i noticed included jquery in html you're not using anywhere, i'll assume you're new jquery , willing use it.
here's do.
first should read on jquery reference. extremely useful.
the things need give attention these:
- jquery selectors - use $('.myclass') instead of getelementsbyclassname
- jquery toggle - or of it's companions (slidetoggle, fadetoggle) asked for.
- and question - stoppropagation - allows trigger toggle clicked , stop event bubbling through dom. (and not trigger it's parents.)
these 3 combined should work. luck.
Comments
Post a Comment