向变量添加一些内容
我有代码
<script type="text/javascript">
var yourImg = document.getElementById('image');
if(yourImg && yourImg.style) {
yourImg.style.height = screen.availWidth;
yourImg.style.width = screen.availHeight;
}
</script>
,我需要将 px 附加到宽度和高度的末尾。
提前致谢, 追赶
I have the code
<script type="text/javascript">
var yourImg = document.getElementById('image');
if(yourImg && yourImg.style) {
yourImg.style.height = screen.availWidth;
yourImg.style.width = screen.availHeight;
}
</script>
And I need to append px to the end of the width and height.
Thanks in Advance,
Chase
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
JavaScript 中的字符串(和其他值)的串联是使用“+”(加号)字符进行的。在你的代码中:
Concatenation of strings (and other values) in javascript is made using the "+" (plus) character. In your code:
您实际上没有提供太多信息,但是:
You didn't really provide much information, but:
yourImg.style.height = screen.availWidth+'px';
yourImg.style.width = screen.availHeight+'px';
yourImg.style.height = screen.availWidth+'px';
yourImg.style.width = screen.availHeight+'px';