This article mainly introduces how to control the hide and show effect of the web page layer by using JavaScript. It involves the skill of javascript to operate the dynamic effect of web page elements and is of great practical value, for more information about how to control the hide and show effect of the web page by using JavaScript, see the following example. Share it with you for your reference. The details are as follows:
Cool DIV layer expansion and contraction effectScript function $ (element) {return element = document. getElementById (element);} function $ D () {var d = $ ('class1content'); var h = d. offsetHeight; var maxh = 300; function dmove () {h + = 50; // set the layer expansion speed if (h> = maxh) {d. style. height = '300px '; clearInterval (iIntervalId);} else {d. style. display = 'block'; d. style. height = h + 'px ';}} iIntervalId = setInterval (dmove, 2);} function $ D2 () {var d =$ ('class1content '); var h = d. offsetHeight; var maxh = 300; function dmove () {h-= 50; // set the layer shrinkage speed if (h <= 0) {d. style. display = 'none'; clearInterval (iIntervalId);} else {d. style. height = h + 'px ';}} iIntervalId = setInterval (dmove, 2);} function $ use () {var d =$ ('class1content '); var sb = $ ('stateid'); if (d. style. display = 'None') {$ D (); sb. innerHTML = 'default';} else {$ D2 (); sb. innerHTML = 'expand ';} scriptHide the DIV Layer
Once there was a sincere love in front of me,
I did not cherish,
I regret it when I lose it,
This is the most painful thing in the world.
If God could give me another chance,
I will say three words to the girl:
I love you.
If you have to add a deadline for this fall in love,
I want ...... 10 thousand years !"
I hope this article will help you design javascript programs.