为什么我的按钮不是一个对象?是因为它在标题中吗?
当我运行此代码时,
var button=document.getElementById("button")
if (navigator.userAgent.indexOf('iPhone') != -1)
{
button.style.left = 250;
}
错误是表达式的结果不是对象。 “button”对象位于 css 文件中,并且它是唯一一个命名为按钮的对象。我做错了什么?这与标题中的按钮有关吗?我正在使用破折号。
When I run this code
var button=document.getElementById("button")
if (navigator.userAgent.indexOf('iPhone') != -1)
{
button.style.left = 250;
}
The error is result of expression is not an object. The object "button" is in the css file and it is the only one named button. What am I doing wrong? Does it have something to do with the button being in the header? I'm using dashcode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
getElementById
为您提供按钮的 HTML DOM 节点;你必须访问它的对象
才能对其执行所有奇特的 Dashcode 操作。 (我有一段时间偶然发现了同样的问题!)Try
getElementById
gives you the HTML DOM node for the button; you have to access itsobject
to do all of the fancy Dashcode stuff to it. (I stumbled around with the same question for a while!)