Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should do what you want if I understand the Question correctly</p> <pre><code>var offset = 0; $$('.tdresult').each(function(chooseClass) { chooseClass.getElements('a').each(function(el){ el.set('rel',offset); el.addEvent('mouseenter', function(uniqueid) { return function() { infoGet(1,uniqueid); } }(offset)); offset++ }); }); </code></pre> <p><code>offset</code> is incremented with the loop but is declared outside of it. Every time the loop runs, it will be the same <code>offset</code> variable being incremented. The loop that was there previously was not necessary.</p> <p>One question though... why would you set the <code>rel</code> attribute to a number? see <a href="http://www.w3schools.com/TAGS/att_a_rel.asp" rel="nofollow noreferrer">http://www.w3schools.com/TAGS/att_a_rel.asp</a> for a list of valid values. Also note that none of the major browsers make use of this attribute anyways. (Epic fail on standards support for everyone)</p> <p><strong>EDIT</strong></p> <p>I noticed what you were trying to do with the event listener. I've modified the code to store the current offset in a closure with the event handler. The function in the event handler is immediately run with the current <code>offset</code>. Inside the function this is referred to as <code>uniqueid</code>. The function then returns the real event handler function but maintains use of the <code>uniqueid</code> variable (not offset, but the value of offset at the time the outer function was called).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload