我想动态更新<h1>
文字以包含<span></span>
代码。
我的jsfiddle显示的javascript如下所示:
$("h1").text("Time Left:<span>" + padNum(glob.gameTimer) + "</span>Best:
<span>" + padNum(glob.bestTime) + "</span>Reaction Time:<span>" +
padNum(glob.reactionTime) + "</span");
答案 0 :(得分:1)
使用html
代替text
$("h1").html("Time Left:<span>" + padNum(glob.gameTimer) + "</span>Best:<span>" + padNum(glob.bestTime) + "</span>Reaction Time:<span>" + padNum(glob.reactionTime) + "</span");
答案 1 :(得分:1)
只需使用$("h1").html()
代替$("h1").text()
。