欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

鼠标悬浮停留三秒后自动显示大图js代码_javascript技巧

程序员文章站 2022-03-26 15:28:11
...
鼠标悬浮停留三秒后显示大图,在网页中还是比较实用的

"); return true; }else{ return false; } }); /* $("#preview") .css("top",(e.pageY - xOffset) + "px") .css("left",(e.pageX + yOffset) + "px") .fadeIn("fast"); */ $('#preview').css({ position:'absolute', left: ($(window).width() - $('#preview').outerWidth())/2, top: ($(window).height() - $('#preview').outerHeight())/2 + $(document).scrollTop() }); setTimeout(function(){ $("#preview").fadeIn("fast"); },3000) }, function(){ this.title = this.t; $("#preview").remove(); }); /* $("a.preview").mousemove(function(e){ $("#preview") .css("top",(e.pageY - xOffset) + "px") .css("left",(e.pageX + yOffset) + "px"); }); */ }; $(document).ready(function(){ imagePreview(); });
后端处理 //ajax function ajaxBigImage() { if(!empty($_POST['goods_id'])){ $goods_id=$_POST['goods_id']; $goodsimg_mod = & m('goodsimage'); $uploadedfile_mod = & m('uploadedfile'); //$file_id = $goodsimg_mod->getOne("select file_id from `ecm_goods_image` WHERE goods_id={$goods_id} ORDER BY file_id DESC"); //获取file_id 字符串 $file_arr = $goodsimg_mod->getCol("select file_id from `ecm_goods_image` WHERE goods_id={$goods_id} ORDER BY file_id DESC"); if(!empty($file_arr)){ $file_str = implode(",",$file_arr); } //echo $file_str; $url_arr = $uploadedfile_mod->getAll("select file_type,file_path from `ecm_uploaded_file` WHERE file_id IN({$file_str}) ORDER BY add_time DESC"); if(!empty($url_arr)){ foreach ($url_arr as $v){ if($v['file_type'] == 'image/gif'){ $url = $v['file_path']; break; exit(); }else { unset($v); } } } //$url = $uploadedfile_mod->getOne("select file_path from `ecm_uploaded_file` WHERE file_id={$file_id} ORDER BY add_time DESC"); if(!empty($url)){ echo $url; exit(); }else{ echo 0; exit(); } }else{ echo 0; } }