Javascript 在div标记中显示文本文件中的特定行
我的网站里有一个txt文件。 我想显示文本文件中的一行,比如第5行,在Javascript 在div标记中显示文本文件中的特定行,javascript,html,Javascript,Html,我的网站里有一个txt文件。 我想显示文本文件中的一行,比如第5行,在 标签。首先,您需要一个函数从中请求文本文件代码 最后,将设置为第五行 load("somefile.txt", function(res){ document.getElementById("some_id").innerHTML = res.responseText.split("\n")[4]; }); load("somefile.txt", function(res){ //do something
标签。首先,您需要一个函数从中请求文本文件代码 最后,将设置为第五行
load("somefile.txt", function(res){
document.getElementById("some_id").innerHTML = res.responseText.split("\n")[4];
});
load("somefile.txt", function(res){
//do something here
});
load("somefile.txt", function(res){
document.getElementById("some_id").innerHTML = res.responseText.split("\n")[4];
});