Skip to main content

load img only when popup appear



First, I'm pretty beginner of jQuery or AJAX.





I've got around 50+ links on a web page and each link has a div#popup which contain a table and a img. It means around 50 pictures are loading when the page loads and it slower the site quite a bit.





So I would like to know if there a way to to load the picture only when mouseover the link?\





Here is the code and script I'm using.







<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8" />

<title>jQuery Popup Div on hover Test</title>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>

<script type="text/javascript">

$(function() {

var moveLeft = 20;

var moveDown = 10;



$('a#trigger').hover(function(e) {

$('div#pop-up').show();

}, function() {

$('div#pop-up').hide();

});



$('a#trigger').mousemove(function(e) {

$("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);

});

});

</script>

<style type="text/css">

.wpm_pag.mng_lts_chp.grp .det a.ttl{

color: #0000ff;

font-size:16px;

line-height:12px;

height:14px;

display:block;

padding:0 0 2px 0

}



.wpm_pag.mng_lts_chp.grp .det div#pop-up table tr td img{

border: 1px solid #e74f25;

}



.wpm_pag.mng_lts_chp.grp .det div#pop-up table{

margin:0;

background-color:#656565;

}



.wpm_pag.mng_lts_chp.grp .det div#pop-up table tr.firstR{

background-color:black;

height: 30px;

font-size: 120%;

}



.wpm_pag.mng_lts_chp.grp .det div#pop-up table tr td.otherRow{

height: 20px;

}



.wpm_pag.mng_lts_chp.grp .det div#pop-up table tr td.otherRow b{

color: #3C3C3C;

}



/* Popup CSS */

.wpm_pag.mng_lts_chp.grp .det div#pop-up {

display: none;

position: absolute;

padding: 0px 5px 5px 5px;

background-color: #000;

color: #FFF;

border: 1px solid #1a1a1a;

font-size: 110%;

font-family:"Comic Sans MS", cursive, sans-serif;

}



</style>





</head>

<body>

<div class="wpm_pag mng_lts_chp grp">

<div class="det">

<p><a href="#" class="ttl" id="trigger">this link</a></p>

<!-- HIDDEN / POP-UP DIV -->

<div id="pop-up">

<table width="650px" cellspacing="0" cellpadding="2px">

<tr class="firstR">

<td colspan="3">Nenee! Ane Tokitoki Kanojo</td>

<td style="text-align: right;" width="25%">Rating</td>

</tr>

<tr>

<td width="200px" rowspan="4"><img height="200" width="200" src ="http://gooddealstore.us/icon/test.jpg" alt="xxx" /></td> /** php echo url

<td class="otherRow" colspan="3"></td>

</tr>

<tr>

<td class="otherRow"><b>Release:</b></td> /** php

<td class="otherRow"><b>Author:</b></td> echo

<td class="otherRow"><b>Artist:</b></td> **/

</tr>

<tr>

<td class="otherRow" colspan="3"><b>Genres:</b></td>

</tr>

<tr>

<td style="vertical-align: top;" colspan="3"></td>

</tr>

</table>

</div>



</div>

</body>

</html>




Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 1 Final Exam 2011 latest (hot hot hot)

  Hi! I have been posted content of ccna1 final exam (latest and only question.) I will post the answer and insert image on sunday. If you care, please subscribe your email an become a first person have full test content. Subcribe now  Some question  have not content because this question have images content. So that can you wait for me? SUNDAY 1. A user sees the command prompt: Router(config-if)# . What task can be performed at this mode? Reload the device. Perform basic tests. Configure individual interfaces. Configure individual terminal lines. 2. Refer to the exhibit. Host A attempts to establish a TCP/IP session with host C. During this attempt, a frame was captured with the source MAC address 0050.7320.D632 and the destination MAC address 0030.8517.44C4. The packet inside the captured frame has an IP source address 192.168.7.5, and the destination IP address is 192.168.219.24. At which point in the network was this packet captured? leaving host A leaving ATL leaving...