[英]how can i add multiple elements efficiently to a div tag on button click?
Hey guys im building a scientific calculator in javascript and i was wondering if there was a better way of doing this because i have to do it for 50+ buttons. 大家好,我用JavaScript构建了一个科学计算器,我想知道是否有更好的方法,因为我必须为50个以上的按钮做这件事。 this is how im currently doing it in my Javascript file it works but i was thinking there must be a more efficient way doing this.
这就是我目前在我的Javascript文件中执行此操作的方式,但是我认为必须有一种更有效的方法来执行此操作。
function percent() {
display = document.getElementById('display')
display = display + " %"
document.getElementById('display').innerText = display
}
the id display is where i want to display the formula before the answer is given to the user. id显示是我想在将答案提供给用户之前显示公式的地方。
您必须添加对象的内部HTML时才添加对象。
display = document.getElementById('display').innerHTML
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.