admin管理员组文章数量:1410724
For simplicity, I'm not going to show too much code, but the variables are set, and the following code is within a conditional. I'm just trying to show the var _offsetX and var _offsetY at the same time.
window.document.getElementById('cssposition').innerHTML = _offsetX _offsetY;
For simplicity, I'm not going to show too much code, but the variables are set, and the following code is within a conditional. I'm just trying to show the var _offsetX and var _offsetY at the same time.
window.document.getElementById('cssposition').innerHTML = _offsetX _offsetY;
Share
Improve this question
asked Sep 10, 2012 at 20:57
William SmithWilliam Smith
8521 gold badge13 silver badges23 bronze badges
2
-
Any reason you can't just use
console.log(_offsetX, _offsetY)
? Looks like you're just debugging to me. – zzzzBov Commented Sep 10, 2012 at 21:00 - window.document.getElementById('cssposition').innerHTML = _offsetX +''+_offsetY; – Shahrokhian Commented Sep 10, 2012 at 21:04
4 Answers
Reset to default 3try:
window.document.getElementById('cssposition').innerHTML = _offsetX +" " + _offsetY;
Just use the +
operator:
window.document.getElementById('cssposition').innerHTML = "X=" + _offsetX + " Y=" + _offsetY;
concat these two variables? ...innerHTML = "" + _offsetX + _offsetY;
Concatenate two variables and then try out, but make a note this a redundant way,
window.document.getElementById('cssposition').innerHTML=_offsetX.concat(_offsetY);
Note: This ignores the space
本文标签: javascriptHow can I set innerHTML equal to two variablesStack Overflow
版权声明:本文标题:javascript - How can I set .innerHTML equal to two variables - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744788588a2625149.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论