【发布时间】:2020-04-30 21:57:23
【问题描述】:
我正在尝试构建一个文本到摩尔斯电码翻译器,并且在尝试获取作为字符串的输入值并将其转换为字母数组时,我收到此错误。
var inputValue = getInputValue();
var inputValueLetters = inputValue.split();
function getInputValue(){
// Selecting the input element and get its value
var inputVal = document.querySelector("#myInput").value;
// Displaying the value
console.log(inputVal);
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Get Text Input Field Value in JavaScript</title>
</head>
<body>
<h1>Morsi: Translate Plain Text Into Morse Code</h1>
<input type="text" placeholder="Type something..." id="myInput">
<button type="button" onclick="getInputValue();">Get Value</button>
<script src="morsi.js"></script>
</body>
</html>
【问题讨论】:
标签: javascript html css console