Reply LinkBack Thread Tools Search this Thread
Old 08-02-2008, 06:17   #1 (permalink)
Aen
i love MUJI
 
Aen's Avatar
 
Join Date: Mar 2007
Location: Psedo Tokyo
Posts: 150
Send a message via AIM to Aen Send a message via MSN to Aen Send a message via Skype™ to Aen
Prototype help with attaching events

I have a bunch of <li>s with onclick="toggleSelection(this)" hardcoded into the markup. How do I use Prototype too attach the toggleSelection function to them w/o usign onclick?
  Reply With Quote
Old 09-02-2008, 12:31   #2 (permalink)
d3mcfadden
Senior Member
 
d3mcfadden's Avatar
 
Join Date: Apr 2005
Location: -
Posts: 686
Send a message via AIM to d3mcfadden
you dont need prototype to do that.

HTML Code:
<ul id="yourUL"> <li>Fuck Off</li> <li>Fuck Off</li> <li>Fuck Off</li> <li>Fuck Off</li> ... </ul> <script type="text/javascript"> var listElements = document.getElementById('yourUL').getElementsByTagName('li'); for (var i=0;i<listElements.length; i++) { listElements[i].onclick = function () { toggleSelection(this); } } </script>
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8