jQuery練習t178,從0到1
阿新 • • 發佈:2021-01-30
技術標籤:JavaScriptjQueryjavascriptjquery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../js/jquery-3.5.1.js"></script> <script> $(function () { //替換元素 //$(A).replaceWith(B) ,表示用B來替換A $("#btn1").click(function () { $("strong").replaceWith("<a href='http://www.baidu.com'>百度</a>"); }); }); </script> </head> <body> <strong>jQuery教程</strong><br> <input type="button" id="btn1" value="替換"> </body> </html>