How to dynamically Replace the banner image path on the JS Tab

Source: Internet
Author: User

How to dynamically Replace the banner image path on the JS Tab

This document describes how to dynamically Replace the banner image path on the JS tab. Share it with you for your reference. The specific analysis is as follows:

Here, we will demonstrate a tab to demonstrate how to dynamically replace an image. a js function is used to define the path of the image to be replaced by a mouse slide.

Parameters are described as follows:

Object of the current trigger event of obj

Class Name of the currently selected hc Element

Content: select the image with the path to be replaced

The url is the image path.

The Code is as follows:

?

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

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN"

Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

<Html xmlns = "http://www.w3.org/1999/xhtml">

<Head>

<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>

<Title> tab dynamically replaces the banner image path </title>

<Script src = "js/jquery. min. js" type = "text/javascript"> </script>

<Script type = "text/javascript">

$ (Document). ready (function (){

HoverFn ($ ("ul li"), "hover_css", $ ("p img"), "big"); // call a function

/*

Specifies the path where the mouse slides over and replaces the image.

Function 2012.8.24

Author zoowar

Parameter description

Object of the current trigger event of obj

Class Name of the currently selected hc Element

Content: select the image with the path to be replaced

The url is the image path.

*/

Function hoverFn (obj, hc, content, url ){

Obj. hover (function (){

Var h_css = hc;

$ (This). addClass (h_css). siblings (). removeClass (h_css );

Var imgUrl = $ (this). attr (url );

Content. attr ("src", imgUrl );

});

}

})

</Script>

<Style type = "text/css">

Div {

Width: 1024px; height: 768px; margin: 0 auto;

}

Ul {

Width: 1024px; height: 40px; margin: 0; padding: 0;

}

Ul li {

Width: 254px; line-height: 40px;

Border-bottom: solid 2px # FB066F; text-align: center;

List-style-type: none; float: left; margin-right: 2px;

Background: # fff;

}

Ul li. hover_css {

Border-bottom: solid 2px # 06F; background: # f0f0f0;

}

P {

Margin: 0; padding: 0; text-align: center; padding-top: 20px;

}

</Style>

</Head>

<Body>

<Div>

<Ul>

<Li class = "hover_css" big = "images/wall_s1.jpg"> landscape </li>

<Li big = "images/wall_s2.jpg"> beauty </li>

<Li big = "images/wall_s3.jpg"> Shuai Pan </li>

<Li big = "images/wall_s4.jpg"> spoof </li>

</Ul>

<P>

</P>

</Div>

</Body>

</Html>

I hope this article will help you design javascript programs.

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.