Jquery provides a few short pieces of code to dynamically add elements and obtain prompt information.

Source: Internet
Author: User

You must first reference the JQ framework.

Then let's take a look at the effect: (the connection cannot be added) You can only view the Haha image for the time being. For the specific effect, see "Play Games" in "My Box" on the left of My blog ":

The following code provides specific annotations.

Let's take a look at the Code:
Copy codeThe Code is as follows:
<Div id = "_ gameinfo" style = "width: 158px; border: 1px # FFC solid; background-color: # FFF; position: fixed; z-index: 101; display: none; padding: 1px; ">
<Div id = "thegameBox" style = "text-align: center;">
<A href = "javascript:;" alt = "WASD key controls the movement of the little girl, and the arrow key controls the movement of the little boy. traps of different colors can only accommodate people of different colors! "Name =" binghuoren "> shenlin contact </a>
<A href = "javascript:;" alt = "click to capture. "Name =" zhishangqiu "> IQ Ball 3 </a>
<A href = "javascript:;" alt = "move the mouse to control the movement of the manipulator, and click the left button to release the magnetic force to seize the goods. "Name =" yunshuchuan "> ship captain's transport </a>
<Script type = "text/javascript" src = "jquery. js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# ThegameBox a"). mousemove (function (ev ){
Var _ Imgsrc = "http://www.bkjia.com/uploads/allimg/131016/23422L525-1.jpg"; // here you need to set the element name the same as your image name
Var _ Ways = $ (this). attr ("alt"); // obtain the alt of the element pointed to by the current mouse
$ ("# _ Gameinfo"). show (); // display the prompt Layer
If (! Ev) {ev = window. event;}; // check whether it is IE
Document. getElementById ("_ gameinfo"). style. left = (ev. clientX + 10) + "px"; // you can specify left as the X-axis distance + 10px of the mouse.
Document. getElementById ("_ gameinfo"). style. top = (ev. clientY + 10) + "px"; // you can specify top as the X-axis distance + 10px of the mouse.
$ ("# _ Gameinfo" 2.16.html (' <br/> '+' <font color =" blue "> operation method: </font> '+ _ Ways + ''); // add content to the prompt layer and input parameters
}). Mouseout (function (){
$ ("# _ Gameinfo"). hide (); // hide the hide layer when you move the cursor away from the element.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.