Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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 在按钮上单击发送整个<;textarea></textarea>;_Javascript_Html - Fatal编程技术网

Javascript 在按钮上单击发送整个<;textarea></textarea>;

Javascript 在按钮上单击发送整个<;textarea></textarea>;,javascript,html,Javascript,Html,我正在努力只发送文本区域的内容,而不是整个标题 <textarea placeholder="Enter your message" id="message"></textarea> <button onclick="sendMsg(message)"> Submit </button> 谢谢大家您获得了元素, 您需要元素的值,所以请尝试 console.log(msg.value) 你的问题真的不清楚。你说的“头”是什么意思?您如何确

我正在努力只发送文本区域的内容,而不是整个标题

<textarea placeholder="Enter your message" id="message"></textarea>
    <button onclick="sendMsg(message)"> Submit </button>

谢谢大家

您获得了
元素
, 您需要元素的值,所以请尝试

console.log(msg.value)

你的问题真的不清楚。你说的“头”是什么意思?您如何确定它正在发送此标头?你应该提供一个和include.I did console.log(message),它给了我请显示
sendMsg
functionDuplicate:@Maths101-如果你的意思是“这个问题没有公认的答案”,那么你是对的,但这并不能阻止它重复你的问题或解决问题的答案。是的,这是正确的答案,谢谢!我会在7分钟内接受
function sendMsg(msg) {
        var req = new XMLHttpRequest();
        console.log(msg);

    }
console.log(msg.value)