HTML标记内容的替换与还原
<!DOCTYPE html> <html> <head> <title>替换元素</title> <!-- Date20190905 --> <meta name="keywords" content="keyword1,keyword2,keyword3"> <meta name="description" content="this is my page"> <meta name="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <script type="text/javascript"> function replaceContent(){ var ljie = document.getElementById("content1") ljie.innerHTML = "<p>你写的东西丢失了……</p>" } function recoverContent(){ var jie = document.getElementById("content1") jie.innerHTML = "<a href='#'>链接</a><span>一句话</span>" } </script> </head> <body> <input type="button" value="替换内容" name="replace0" onClick="replaceContent()"> <input type="button" value="还原内容" name="replace1" onClick="recoverContent()"> <form action="" id = "content1"> <a href="#">链接</a> <span>一句话</span> </form> </body> </html>
2019-09-05 13:16:49