我希望蚂蚁可以提供帮助。 一定很容易,但找不到简单的方法吗?如何在我刚刚放入游戏的按钮中添加一个Class和href属性?
displayScore: function() {
var gameOverHTML = "<h1>Game Over</h1>";
gameOverHTML += "<h2> Your score is: " +
quiz.score +
"</h2><br>" +
"<a><button>Play again</button></a>";
this.populateIdWithHTML("quiz", gameOverHTML);
},
populateIdWithHTML: function(id, text) {
var element = document.getElementById(id);
element.innerHTML = text;
},
答案 0 :(得分:0)
使用类,您可以尝试使用jQuery。首先在项目中导入jQuery CDN并执行以下操作:
@media only screen and (max-width: 725px) {
/* a lot of styles for small screens */
}
@media only screen and (min-width: 725px) {
/* a lot of styles for big screens */
}
答案 1 :(得分:0)
你的意思是这样的..
<button><a href="#">Play again</a></button>
$("button").addClass("name of class to be added ");
希望它能奏效。
答案 2 :(得分:0)
<div class="name of class to be added "><button><a href="#">Play again</a></button></div>
这会起作用