Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're doing a couple of things wrong. Check <a href="http://db.tt/lUVqgm9G" rel="nofollow">this</a> out:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;style type="text/css"&gt; #apDiv1 { position:absolute; width:400px; height:327px; z-index:1; left: 105px; top: 98px; } &lt;/style&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ var img = $('.image'); if(img.length &gt; 0){ var offset = img.offset(); function mouse(evt){ var center_x = (offset.left) + (img.width()/2); var center_y = (offset.top) + (img.height()/2); var mouse_x = evt.pageX; var mouse_y = evt.pageY; var radians = Math.atan2(mouse_x - center_x, mouse_y - center_y); var degree = (radians * (180 / Math.PI) * -1) + 90; img.css('-moz-transform', 'rotate('+degree+'deg)'); img.css('-webkit-transform', 'rotate('+degree+'deg)'); img.css('-o-transform', 'rotate('+degree+'deg)'); img.css('-ms-transform', 'rotate('+degree+'deg)'); } $(document).mousedown(mouse); } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="apDiv1"&gt;&lt;img src="http://img402.imageshack.us/img402/2017/bighand.png" class="image"/&gt; &lt;br&gt; (Not actual picture I'm trying to rotate, but it'll do for now) &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>As others have pointed out, you must have dedicated script tag for external js. Also, you should include your jQuery code in $(document).ready(your_function_here);</p> <p>EDIT: included code in the answer.</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.
 

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