我试图在变量t = <100
时显示一些文字,但它不起作用,我不明白为什么:(
var t = 100;
function tel(){
t--;
console.log(t);
return document.getElementById("lol").innerHTML = t;
}
if (t < 97){
document.getElementById('nba').innerHTML = ('Ja he');
}else {
document.getElementById('nba').innerHTML = ('Blijf klikken')
}
if (t < 35){
document.write("op de helft");
}
<!DOCTYPE html>
<html>
<head>
<title>madafaka</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrap">
<p id="tel"></p>
<br>
<button id="lol" type="button" onclick="tel()">Klik!</button>
<p id="nba"></p>
<script src="jav.js"></script>
</div>
</body>
</html>
好像没有打印文字,我不明白为什么。
答案 0 :(得分:2)
您必须使用函数中的比较代码= tel();
protected void Page_Load(object sender, EventArgs e)
{
ddlGM.Attributes.Add("OnClick", "dropdownload()");
if (!IsPostBack)
{ FillAccounts();
}
}
protected void btnHidden_Click(object sender, EventArgs e)
{
DataView dvfilters = (DataView)(Cache["FiltersData"]);
dtt = dvfilters.ToTable();
ddlGM.DataSource = dtt;
ddlGM.DataValueField = "GlobalMarket";
ddlGM.DataBind();
RemoveDuplicateItems(ddlGM);
SortDDL(ref ddlGM);
//ddlGM.Items.Insert(0, "All");
}
&#13;
var t = 100;
function tel(){
t--;
console.log(t);
// compares
if (t < 97){
document.getElementById('nba').innerHTML = ('Ja he');
}
else {
document.getElementById('nba').innerHTML = ('Blijf klikken')
}
if (t < 35){
document.write("op de helft");
}
return document.getElementById("lol").innerHTML = t;
}
&#13;
.as-console-wrapper { max-height: 10% !important; }
&#13;
答案 1 :(得分:0)
您在if(){} else{}
之外验证您的代码,并在检查完成之前返回新值。请记住,您的浏览器从上到下阅读。当计数器低于35时,您的按钮将被替换为“op de helft”。