Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pomocí <img src=... onMouseOver='getMousePos(this, myFunction)'> chci spustit tuto funkci, ale hlásí mi to chybu
- [pre]
- var getMousePos = function (that, myFunction = Null){
- var imgWidth = $(that).width();
- var imgHeight = $(that).height();
- var imgPosition = $(that).position();
- imgPosition.left = Math.round(imgPosition.left);
- imgPosition.right = imgPosition.left + imgWidth;
- imgPosition.top = Math.round(imgPosition.top);
- imgPosition.bottom = imgPosition.top + imgHeight;
- console.log(imgPosition);
- if ( mousePos.x > imgPosition.left &&
- mousePos.x < imgPosition.right &&
- mousePos.y > imgPosition.top &&
- mousePos.y < imgPosition.bottom
- )
- {
- console.log("You clicked in the image");
- if ( myFunction )
- {
- return myFunction();
- }
- }
- }
- [/pre]
- Nevíte co je špatně?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement