JQuery: using .LIVE problems
Posted
by TeddTedd
on Stack Overflow
See other posts from Stack Overflow
or by TeddTedd
Published on 2010-05-11T20:15:19Z
Indexed on
2010/05/11
20:24 UTC
Read the original article
Hit count: 220
jQuery
|JavaScript
I have the following JQuery code:
$("#myDIV li:eq(0)").live('click',function(){ funcA(); });
$("#myDIV li:eq(1)").live('click',function(){ funcB(); });
$("#myDIV li:eq(2)").live('click',function(){ funcC(); });
$("#myDIV li:eq(3)").live('click',function(){ funcD(); });
And realized it's really inefficient.
So I tried the following, which I believe is much more effect; however, the code does not work:
var tab_node = $("#myDIV li");
tab_node.eq(0).live('click',function(){ funcA(); });
tab_node.eq(1).live('click',function(){ funcB(); });
tab_node.eq(2).live('click',function(){ funcC(); });
tab_node.eq(3).live('click',function(){ funcD(); });
Any idea how I can make my code more efficient while also work?
UPDATE:
From the answers below, it sounds like these two statements are not equalavent.
New Question: Is there any way to run my original code more efficient?
© Stack Overflow or respective owner