开发者

Why is my button not an object? Is it because it is in the header?

开发者 https://www.devze.com 2023-03-24 14:33 出处:网络
When I run this code var button=document.getElementById(\"button\") if (navigator.userAgent.indexOf(\'iPhone\') != -1)

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 a开发者_如何转开发m I doing wrong? Does it have something to do with the button being in the header? I'm using 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!)

0

精彩评论

暂无评论...
验证码 换一张
取 消