先来看一下官方提供的API(http://www.prototypejs.org/api/element),这里集中了所有的Element中的元素,我这里只对remove和replace进行测试,come on!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Untitled Document</title>
- <script src="prototype.js"></script>
- <script>
- function removeTest(){
- Element.remove('pear');
- }
- function replaceTest(){
- Element.replace('apple','pig小猪');
- }
- </script>
- </head>
- <body>
- <div id="apple">苹果</div>
- <div id="banana">香蕉</div>
- <div id="orange">桔子</div>
- <div id="pear">梨</div>
- <div id="peach">桃子</div>
- <div id="watermelon">西瓜</div>
- <input type="button" value="Remove" onclick="removeTest()"/>
- <input type="button" value="Replace" onclick="replaceTest()"/>
- </body>
- </html>
运行示意图
从以上两个图中可以明显的看到差别所在吧。