tags:

views:

48

answers:

3

The jquery popup I created using the jquery show function, fades away in few seconds which is not intended. I want the popup to stay...

How can i tell jquery to do so?

heres is my code,

jQuery(document).ready(function(){
jQuery('#popuup_div.popup_msg').hide();
$(a.xyz).click(function(e)
{
  var height = jQuery('#popuup_div').height();
  var width = jQuery('#popuup_div').width();
  leftVal=e.pageX-(width/1.5)+"px";
  topVal=e.pageY-(height/13)+"px";

  jQuery('#popuup_div').css({left:leftVal,top:topVal}).show();
});

jQuery('#image').click(function(e)
{
jQuery('#popuup_div').fadeOut('fast');
});
});

html

<div id='popuup_div' class='popup_msg'>
<div id='image'>
 gets the image 
</div>
 <br>
some message
 </div>

css:

.popup_msg{
position:absolute;
z-index:100;
width:700px;
height:250px;
text-align:justify;
color:Black;
font: 14px Verdana, Arial, Helvetica, sans-serif;
background-color:yellow;
}
+1  A: 

What plugin/function did you use to create the popup? Search for setTimeout throughout your JavaScript code, and paste the snippet

(Use Web Developer add-on for firefox, then after having the page loaded completely, on the Web Developer toolbar go to Information > View JavaScript, and search for "setTimeout" there.)

Swizzy
hi, i just added my code in my question....plz check it, and let me know your answer... thanks
tecks
Check this out, are you looking for something similar?http://jsfiddle.net/WDtaw/
Swizzy
Hi swizzy, that actually helped me to figure out the problem.... I wrote the jquery popup in cakephp, and that popup was under some other divs of layout...... nice link btw
tecks
A: 

If you are using a third party plugin for jQuery's library your not going about this the best way. The easiest way to "fade in" an element would be to use jQuery's native $.fadeIn();

Here's an example:

$("#myDiv").fadeIn(1000);

Or an Example of jQuery's $.show();

$("#myDiv").show(1000);

In both cases the div you have set up (which should have a style of "display:none;") will display within 1000 milliseconds. Using either one of these should not "fade out" or hide the element after any amount of time (since you have not written any code to do that).

If you have any questions just ask :)

hi clarke, thanks for being so kind, :)... anyways i just added my code in my question....plz check it, and let me know your answer... thanks
tecks
+2  A: 

This code:

jQuery('#image').click(function(e)
{
    jQuery('#popuup_div').fadeOut('fast');
});

is the code the fades away the div. Based on the code you provided, the pop up div won't fade away unless you click on the image div. Are you sure the div always fades away even if you don't click anything? There is nothing else in your posted code that would cause your pop up to fade.

rosscj2533
yea... even if i dont click anything, it fades away in 5-6 seconds......
tecks
It could be something elsewhere in your code, if you post the full page I'll look it over. I tested with your exact code except I added `<a class='xyz'>click me</a>` after your last div, and changed your `$(a.xyz)` selector to `$('a.xyz')`.
rosscj2533
Thanks rosscj, but i found out the reason for the prob, am still working on it although... as you said, it was some other code, that was creating the prob..
tecks