How to implement the scroll bar effect using JavaScript _ PHP Tutorial

Source: Internet
Author: User
JavaScript to implement the scroll bar effect. How to implement the scroll bar effect in JavaScript this article mainly introduces how to implement the scroll bar effect in JavaScript and how to implement the scroll bar effect in JavaScript Operations on html element javascript.

 How to implement the scroll bar effect using JavaScript

This article mainly introduces how to implement the scroll bar effect in JavaScript. it involves some techniques related to javascript operations on html elements to implement scrolling. it is very useful. For more information, see

This article describes how to implement the scroll bar effect in JavaScript. Share it with you for your reference. The details are 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

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

Script

Window. onload = function (){

Var oDiv = document. getElementById ('p1 ');

Var oUl = oDiv. getElementsByTagName ('Ul ') [0];

Var oLi = oUl. getElementsByTagName ('Lil ');

Var oLeft = document. getElementById ('leftdiv ');

Var oright = document. getElementById ('rightdiv ');

OUl. innerHTML + = oUl. innerHTML;

OUl. style. width = oLi [0]. offsetWidth * oLi. length + 'px ';

Var speed =-2;

Function move (){

If (oUl. offsetLeft <-oUl. offsetWidth/2 ){

OUl. style. left = '0 ';

} Else if (oUl. offsetLeft> 0 ){

OUl. style. left =-oUl. offsetWidth/2 + 'px ';

}

OUl. style. left = oUl. offsetLeft + speed + 'px ';

};

Var timer = setInterval (move, 30 );

OLeft. onclick = function (){

Speed =-2;

};

Oright. onclick = function (){

Speed = 2;

};

OUl. onmouseover = function (){

ClearInterval (timer );

};

OUl. onmouseout = function (){

Timer = setInterval (move, 30 );

};

}

Script

I hope this article will help you design javascript programs.

How to implement scroll bar effect in JavaScript this article mainly introduces how to implement scroll bar effect in JavaScript, involving javascript operations on html elements...

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.