<! DOCTYPE html > < html > < head > < meta charset ="utf-8" /> < title ></ title > < script src ="js/JQ3.3.1.js" ></ script > < script type ="text/javascript" > function fun(){ var msgValue = $(msg).val(); // The val() function is used to get the content console.log( "The input content is: "+msgValue) } function fun2(){ var msgValue = $(msg).val( " Generate content with one click " ); // The val() function also has the function of setting content } </script> </head> <body> 输入消息:<input type="text" name="msg" id="msg" /> <input type="button" value="输出内容" onclick="fun()"/> <input type="button" value="设置内容" onclick="fun2()" /> </body> </html>