I’m trying this demo here
In HTML:
...
<body>
<div id="button-wrapper" style="position: absolute; opacity: 1; width: 27px; height: 20px;">
<input type="submit" value="submit">
</div>
</body>
...
In jQuery:
$(document).ready(function(){
$("#button-wrapper").parent().mousemove(function(e) {
jQuery("#button-wrapper").css({
top : e.pageY - 10,
left : e.pageX + 30
});
});
});
An error occurs when I move the mouse on body. The submit button can’t run on mouse move event. How should I fix this?
Try this:
You should first use all
$(document)since you are trying selectingparent()of your div which isbodywhich can be easilythe documentitself. Then useon()for live DOM interpretation.Then translate this
jQuery("#button-wrapper")to$("#button-wrapper")just because if you use one, don’t use the other.Also translate
$(document).ready(function(){});part into$(function(){});.