set scrolltop of one div in the other one's scroll event cause endless loop
<p>I am trying to write a jquery plugin for reading different contents synchronously in two divs. When one div scrolls, the other div's <code>scrollTop</code> will be set in the event's code.</p>

<p>The problem is the scroll event of the other div will be fired when <code>scrollTop</code> is set, then the first div's <code>scrollTop</code> will set and the other div's scroll event will be fired (followed by an endless loop).</p>

<p>It is similar with this situation: </p>

<ol>
<li>Two soldiers receive a same command, "jump when you see the other one jump".</li>
<li>Then, when you order one of them to jump, they will jump forever.</li>
</ol>

<p>Sample code:</p>

<pre><code>function syncReading(contentDiv) {
    this.contentDiv = contentDiv;
    contentDiv.onscroll = function(){
        this.Scroll();
    }
}

syncReading.prototype.Scroll = function() {
    //calc scrolldistance;
    for(var i in divCollection)
    {
        if(this != divCollection[i])
        {
            divCollection[i].scrollTop=scrollDistance;
        }
    }
}

var one = new syncReading(getelementbyid("one");
var other = new syncReading(getelementbyid("other"));
var divCollection = [one,other];
</code></pre>

<p>(English is not my native language.)</p>
