Home Web Front-end JS Tutorial Automatically display the large image js code after hovering the mouse for three seconds_javascript skills

Automatically display the large image js code after hovering the mouse for three seconds_javascript skills

May 16, 2016 pm 04:36 PM

The large image will be displayed after hovering the mouse for three seconds, which is quite practical in web pages

1

2

3

4

5

6

7

<style>

*{margin:0;padding:0;list-style-type:none;}

img,a{border:0;}

.piccon{height:75px;margin:100px 0 0 50px;}

.piccon li{float:left;padding:0 10px;}

#preview{position:absolute;border:1px solid #ccc;background:#333;padding:5px;display:none;color:#fff;z-index:2000;}

</style>

Copy after login

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

<script type="text/javascript">

this.imagePreview = function(){

 

xOffset = 10;

yOffset = 30;

var urll;

$(".widget .ks-content a,.box .ks-switchable-content div li a").hover(function(){

//$(".widget .ks-content a").hover(function(e){

//var goods_id = $(this).attr("href").replace("goods/", "");

var goods_id = $(this).attr("href").replace("index.php&#63;app=goods&id=", "");

this.t = this.title;

this.title = " ";

var c = (this.t != "") &#63; "<br/>" + this.t : " ";

 

$.post("index.php&#63;app=default&act=ajaxBigImage", {goods_id: goods_id},function(data){

$.ajaxSettings.async = false;

if(data!=0){

urll = data;

 

$("body").append("<div id='preview'><img src="+ urll +" />"+ c +"</div>");

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();

});

 

</script>

 

 

<div id="_widget_579" name="jdr_sale_list" widget_type="widget" class="widget">

<div class="sale_list mt10 clearfix">

<h2>销售排行</h2>

<div>

<ul class="ks-nav ks-nav1476271702">

<li class="ks-active nav1">特效礼花</li>

<li class="nav2">套餐烟花</li>

</ul>

<div class="ks-content">

<ul class="box" id="box1_1476271702">

<li >

<div class="pic"><a href="index.php&#63;app=goods&id=331"><img alt="【81发六锦系列组合烟花】" src="data/files/store_927/goods_51/small_201312121557314803.JPG" height="60" width="60"></a><b>1</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=331">【81发六锦系列组合烟花】</a></div>

<div class="price">&yen;200.00</div>

</div>

</li>

<li >

<div class="pic"><a href="index.php&#63;app=goods&id=336"><img alt="【八喜系列组合烟花】五福临门、六六大顺、七星高照、八方得利" src="data/files/store_927/goods_33/small_201312121630335585.JPG" height="60" width="60"></a><b>2</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=336">【八喜系列组合烟花】五福临门、六六大顺、七星高照、八方得利</a></div>

<div class="price">&yen;180.00</div>

</div>

</li>

<li >

<div class="pic"><a href="index.php&#63;app=goods&id=375"><img alt="【五福系列组合烟花】福运长流、福满人间、福寿满堂、福如东海、福到财来" src="data/files/store_927/goods_193/small_201312130956337166.JPG" height="60" width="60"></a><b>3</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=375">【五福系列组合烟花】福运长流、福满人间、福寿满堂、福如东海、福到财来</a></div>

<div class="price">&yen;260.00</div>

</div>

</li>

<li style="border-color:#fff;" >

<div class="pic"><a href="index.php&#63;app=goods&id=399"><img alt="合家欢乐组合烟花\小礼花" src="data/files/store_927/goods_197/small_201312131059578989.JPG" height="60" width="60"></a><b>4</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=399">合家欢乐组合烟花\小礼花</a></div>

<div class="price">&yen;480.00</div>

</div>

</li>

</ul>

<ul class="box box2" id="box2_1476271702" style="display:none;">

<li >

<div class="pic"><a href="index.php&#63;app=goods&id=310"><img alt="套餐烟花-儿孙满堂" src="data/files/store_927/goods_92/small_201312121508128170.jpg" height="60" width="60"></a> <b>1</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=310">套餐烟花-儿孙满堂</a></div>

<div class="price">&yen;888.00</div>

</div>

</li>

<li >

<div class="pic"><a href="index.php&#63;app=goods&id=305"><img alt="套餐烟花-六六大顺" src="data/files/store_927/goods_136/small_201312121455369033.jpg" height="60" width="60"></a> <b>2</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=305">套餐烟花-六六大顺</a></div>

<div class="price">&yen;666.00</div>

</div>

</li>

<li >

<div class="pic"><a href="index.php&#63;app=goods&id=303"><img alt="套餐烟花-一路顺发" src="data/files/store_927/goods_118/small_201312121451582290.jpg" height="60" width="60"></a> <b>3</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=303">套餐烟花-一路顺发</a></div>

<div class="price">&yen;1,688.00</div>

</div>

</li>

<li style="border-color:#fff;" >

<div class="pic"><a href="index.php&#63;app=goods&id=300"><img alt="套餐烟花-喜事连连" src="data/files/store_927/goods_14/small_201312121443346243.jpg" height="60" width="60"></a> <b>4</b></div>

<div class="info">

<div class="title"><a href="index.php&#63;app=goods&id=300">套餐烟花-喜事连连</a></div>

<div class="price">&yen;1,288.00</div>

</div>

</li>

</ul>

</div>

</div>

</div>

 

 

后端处理

 

//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;

}

}

Copy after login

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1677
14
PHP Tutorial
1280
29
C# Tutorial
1257
24
Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

JavaScript and the Web: Core Functionality and Use Cases JavaScript and the Web: Core Functionality and Use Cases Apr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

JavaScript in Action: Real-World Examples and Projects JavaScript in Action: Real-World Examples and Projects Apr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

Understanding the JavaScript Engine: Implementation Details Understanding the JavaScript Engine: Implementation Details Apr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: Development Environments and Tools Python vs. JavaScript: Development Environments and Tools Apr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

The Role of C/C   in JavaScript Interpreters and Compilers The Role of C/C in JavaScript Interpreters and Compilers Apr 20, 2025 am 12:01 AM

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

Python vs. JavaScript: Use Cases and Applications Compared Python vs. JavaScript: Use Cases and Applications Compared Apr 21, 2025 am 12:01 AM

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

From Websites to Apps: The Diverse Applications of JavaScript From Websites to Apps: The Diverse Applications of JavaScript Apr 22, 2025 am 12:02 AM

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

See all articles