¡@

Home 

2014/10/16 ¤W¤È 12:05:53

jquery Programming Glossary: numspans

Event doesn't get added in a for-loop

http://stackoverflow.com/questions/6332589/event-doesnt-get-added-in-a-for-loop

that causes the span element in front of it to be replaced. script type text javascript document .ready function var numSpans span .length for n 0 n numSpans n a#update n .click function e 'span#sp' n .replaceWith 'this' e.preventDefault script.. front of it to be replaced. script type text javascript document .ready function var numSpans span .length for n 0 n numSpans n a#update n .click function e 'span#sp' n .replaceWith 'this' e.preventDefault script For some reason this does not work... of invocation not the point of declaration. You can see this by adding an alert call document .ready function var numSpans span .length for n 1 n numSpans n a#update n .click function e alert n Alerts '6' 'span#sp' n .replaceWith 'this' e.preventDefault..