我的html文件中有此按钮:

<button id="btn1" name="subject" type="submit" class="btn btn-primary" value="html_j">kll</button>


然后我有一个ID为'sendBtn'的SendButton.txt文件,其中只有1行:

Send Message


我希望.txt文件中的消息成为按钮的文本。有什么提示吗? T_T

我已经尝试通过在main.js中编写此代码来成功将默认消息设置为按钮:

var y = document.getElementById('sendBtn');
y.innerText = "Sendddd"


但是我不知道如何从文件中导入文本...

最佳答案

你不能这样做。您可以使用Node.js读/写文件。无法从前端读取文件的内容。

关于javascript - 将文本从txt文件导入按钮文本(html),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54093262/

10-12 12:55
查看更多