HTML / JS用户输入

问题描述 投票:0回答:2

我正在尝试使用html和js从输入字段中提取文本输入。

HTML

<div class="inputarea">
        <input type="text" value ='' id='myInput' placeholder="What do I need to do?"> 
        <button onclick='todolist().submit()'>SUBMIT</button>
</div>

JS

function todolist(){
    function first(){
        window.open("todolist.html")
    }
    function submit(){
        var userinput = document.getElementById('myInput').value;
        console.log(userinput);
    }
}

当我按下提交时,控制台显示“ Uncaught TypeError:无法读取未定义的属性'submit'”

任何帮助将不胜感激。

Sam。

javascript html
2个回答
3
投票

尝试返回函数


1
投票

可能todolist

© www.soinside.com 2019 - 2024. All rights reserved.