Home > Web Front-end > JS Tutorial > Use jQuary to achieve text floating prompt effect sample code_jquery

Use jQuary to achieve text floating prompt effect sample code_jquery

WBOY
Release: 2016-05-16 17:06:44
Original
1149 people have browsed it
Copy code The code is as follows:



< ;meta charset="utf-8"/>

<script> <br>/*Text prompt*/ <br>/* <br> (1) When the mouse moves in, create a div whose content is the value of the title attribute <br> (2) Specify the position and set css style <br> (3) When the mouse moves out, remove the div <br> (4) When the mouse moves, the coordinates of the X and Y axes should change accordingly <br>*/ <br>$(function(){ <br>var x = 7; <br>var y = 8; <br>$("a.tip").hover(function(){ <br>var title = this.title; <br>var $div = $("<div id='newTip'>" title "</div>"); <br>$("body").append($div); <br>$div.css({" position":"absolute","background":"pink"}); <br>},function(){ <br>$("#newTip").remove(); <br>}).mousemove(function (e){ <br>var $div = $("#newTip").css({"left":(e.pageX x) 'px',"top":(e.pageY y) 'px'} ); <br>}); <br>}) <br></script>


This is my tip


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template