我有一个div标签
<div id="generic" style="color:red;font-style:italic;font-weight:bold"></div>
要在我正在使用的位置打印文本
document.getElementById("generic").innerHTML= "Please wait";
在同一位置,我需要在同一个文件中打印不同的消息
document.getElementById("generic").innerHTML= "Processing done";
由于在同一文件中的不同时刻使用相同的div标签打印了两个不同的消息,因此它会被覆盖,只会显示第二条消息..
有人可以建议如何纠正这两个文本......
答案 0 :(得分:0)
你想追加?
document.getElementById("generic").innerHTML= "Please wait";
//sometime later
document.getElementById("generic").innerHTML+="Processing done"
答案 1 :(得分:0)
将其更改为此,因此它会将第二个文本添加到第一个文本(请注意+
运算符):
document.getElementById("generic").innerHTML = "Please wait";
document.getElementById("generic").innerHTML += "Processing done";
您还可以将generic
元素存储在变量中以缩短代码,如下所示:
var genericElement = document.getElementById("generic");
genericElement.innerHTML = "Please wait";
genericElement.innerHTML += "Processing done";
答案 2 :(得分:0)
您可以像连接字符串时那样连接innerHTML。
input{
stdin{}
file{
type => "txt"
path => "C:\HA\accesslog\trial.log"
start_position => "beginning"
}
}
filter{
grok{
match => {"message" => ["%{IP:ClientAddr}%{SPACE}%{NOTSPACE:access_date}%{SPACE}%{TIME:access_time}%{SPACE}%{NOTSPACE:x-eap.wlsCustomLogField.VirtualHost}%{SPACE}%{WORD:cs-method}%{SPACE}%{PATH:cs-uri-stem}%{SPACE}%{PROG:x-eap.wlsCustomLogField.Protocol}%{SPACE}%{NUMBER:sc-status}%{SPACE}%{NUMBER:bytes}%{SPACE}%{NOTSPACE:x-eap.wlsCustomLogField.RequestedSessionId}%{SPACE}%{PROG:x-eap.wlsCustomLogField.Ecid}%{SPACE}%{NUMBER:x-eap.wlsCustomLogField.ThreadId}%{SPACE}%{NUMBER:x-eap.wlsCustomLogField.EndTs}%{SPACE}%{NUMBER:time-taken}"]}
}
if "_grokparsefailure" in [tags] {
drop { }
}
}
output{
elasticsearch {
hosts => ["localhost:9200"]
index => "logstash-%{+YYYY.MM.dd}"
template_overwrite => true
}
stdout { codec => rubydebug }
}
答案 3 :(得分:0)
首先,您必须知道两条消息之间的时间。使用 setTimeout(),您可以执行以下操作:
function setText(id, message) {
var el = document.getElementById(id);
el.innerHTML = message;
}
var time = 1000; // Time between the two messages
setText("generic", "Please wait"); // First message
setTimeout(function() {
setText("generic", "Processing done"); // After one second run second message
}, time);