如何在HTML中多次显示一个变量?当变量香蕉增加时,它仅使用变量香蕉增加其中一个跨度。
skipper = true
def main():
decision_function()
calc_function1()
calc_function2()
calc_function3()
decision_function(reqierment)
def decision_function():
if skipper == True:
do this
skipper = False
else:
do that
答案 0 :(得分:1)
getElementsByClassName
代替getElementById
innerHTML
答案 1 :(得分:0)
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<h3>Example Code</h3>
<button class="button" onclick="Addbanana()">Add 1 Banana</button>
<p>Bananas = <span class="banana"> 0 </span></p>
<p>Bananas = <span class="banana"> 0 </span></p>
<p>Bananas = <span class="banana"> 0 </span></p>
<script>
var banana = 0;
function Addbanana(){
banana = banana + 1;
$(".banana").each(function() {
$(".banana").html(banana);
})
}
</script>
</body>
</html>