<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="./js/jquery.min.js"></script> </head> <body> <div>你好</div> <input type="text" value="123"> <script> //获取元素内容 console.log($("div").html()); //获取设置元素文本内容 $("div").html("123"); console.log($("div").text()); $("div").text("1234"); //获取设置表单值 console.log($("input").val()); $("input").val("123"); </script> </body> </html>