javascript - Changing text with position change of mouse pointer? -


i trying write script want put in html website. script changes text change in mouse cursor position. eg. if user on (x,y)=(1,1) text displayed while if on (x,y)=(2,2) other random text displayed.

var text = [ 'i human.'] 

i not sure how connect mouse event. if pointer moves, display random text list of text. can provide code? me. thank you!

since you're using jquery, can use mouse move function , if want effects, can use jquery's animate.

javascript:

$(document).mousemove(function(){    var randtext = text[math.floor(math.random()*text.length)];    var div = $("#textdiv");    div.stop().animate({"opacity": "0"}, 100, function(){        $(this).html(randtext);        $(this).stop().animate({"opacity": "1.0"}, 100);    }); }); 

html:

<div id="textdiv"></div> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -