<html> <head> <script type="text/javascript"> function setMaxHeight() { document.getElementById("p1").style.maxHeight="10px"; } </script> </head> <body> <p id="p1">This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.</p> <input type="button" onclick="setMaxHeight()" value="Set max height" /> </body> </html>
结果:
编辑上面的代码,点击查看结果。
yige.org
- 试一个