为什么我的按钮不是一个对象?是因为它在标题中吗?

发布于 2024-11-27 09:05:56 字数 256 浏览 7 评论 0原文

当我运行此代码时,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻泪 2024-12-04 09:05:56

尝试使用

var button=document.getElementById("button").object

getElementById 为您提供按钮的 HTML DOM 节点;你必须访问它的对象才能对其执行所有奇特的 Dashcode 操作。 (我有一段时间偶然发现了同样的问题!)

Try

var button=document.getElementById("button").object

getElementById gives you the HTML DOM node for the button; you have to access its object to do all of the fancy Dashcode stuff to it. (I stumbled around with the same question for a while!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文