Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 简单jquery无法打印输入值_Javascript_Jquery_Html_Browser - Fatal编程技术网

Javascript 简单jquery无法打印输入值

Javascript 简单jquery无法打印输入值,javascript,jquery,html,browser,Javascript,Jquery,Html,Browser,下面是一个简单的代码,它接受输入并在同一页上打印。但当我点击按钮时,它不工作。请帮忙 <html> <head> <script> function changeHTML() { $("#withjQuery").html($("#theInput").val()); } </script> <body> <input type='text' id='theInput' value='Write here' />

下面是一个简单的代码,它接受输入并在同一页上打印。但当我点击按钮时,它不工作。请帮忙

<html>
<head>
<script>
function changeHTML() {
    $("#withjQuery").html($("#theInput").val());
}

</script>

<body>
<input type='text' id='theInput' value='Write here' />

<input type='button' onClick='changeHTML();' value='See what you wrote with jQuery.html'/>

<div id="withjQuery"></div>

</body>

</head>

函数changeHTML(){
$(“#withjQuery”).html($(“#输入”).val());
}

页面中没有jQuery库



函数changeHTML(){
$(“#withjQuery”).html($(“#输入”).val());
}

演示:

+1。事实上,我评论说它对我有用,然后才意识到图书馆不见了:)@Harry也对我有用。。。我先试过小提琴。。。才意识到哦。!!好的,谢谢……)\在你的头脑中加入这个
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
function changeHTML() {
    $("#withjQuery").html($("#theInput").val());
}

</script>

</head>

<body>
<input type='text' id='theInput' value='Write here' />

<input type='button' onClick='changeHTML();' value='See what you wrote with jQuery.html'/>

<div id="withjQuery"></div>

</body>
</html>