Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have solved this problem myself by using the position of the button and the mouse to do each operation, this have added more flexibility.</p> <p>Here's part of the code: 1. this is the way to get the top, left, right, bottom arguments:</p> <pre><code>var yesPosition = $('.yes').position(), noPosition = $('.no').position(), yesWidth = $('.yes').width(), yesHeight = $('.yes').height(), noWidth = $('.no').width(), noHeight = $('.no').height(); //get the relative position of yes/no button var yesTop = yesPosition.top, yesLeft = yesPosition.left, yesBottom = yesTop + yesHeight, yesRight = yesLeft + yesWidth, noTop = noPosition.top, noLeft = noPosition.left, noBottom = noTop + noHeight, noRight = noLeft + noWidth; </code></pre> <p>/<em>2. this is a replace of hover() method, only when the mouse is moving and in the range of one of the button, we can do the operations we want, pretty cool right :)</em>/</p> <pre><code>if(isMouseUp == false &amp;&amp; event.pageX &gt;= yesLeft &amp;&amp; event.pageX &lt;= yesRight &amp;&amp; event.pageY &gt;= yesTop &amp;&amp; event.pageY &lt;= yesBottom) { $('input[name=test]').val("X: " + event.pageX + ", " + event.pageY); $('.yes').attr("src","images/submit_confirm.png"); $('input[name=stimulusResponse]').val("yes hover"); $('.no').attr("src","images/no.png"); } else if (isMouseUp == false &amp;&amp; event.pageX &gt;= noLeft &amp;&amp; event.pageX &lt;= noRight &amp;&amp; event.pageY &gt;= noTop &amp;&amp; event.pageY &lt;= noBottom) { $('input[name=test]').val("X: " + event.pageX + ", " + event.pageY); $('.no').attr("src","images/submit_confirm.png"); $('input[name=stimulusResponse]').val("no hover"); $('.yes').attr("src","images/yes.png"); } else { $('input[name=stimulusResponse]').val(""); $('.yes').attr("src","images/yes.png"); $('.no').attr("src","images/no.png"); } </code></pre>
 

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