开发者

Overflow-y not working in javascript?

I want to make an onClick event on the link.

the code:

 <a onclick="document.getElementById('myBodyID').style.overflow-y='hidden'" title=开发者_C百科"my title">Anchor text</a>

Why isn't this working? I want to disable vertical scrolling when the link is clicked.

How could I fix this code? It is not working at the moment :(


Use:

document.getElementById('myBodyID').style.overflowY='hidden'

As CSS properties with special characters are camel cased. You can also use brackets (document.getElementById('myBodyID').style["overflow-y"]).


You cannot use - inside such a property literal. Instead, use the [] notation.

.style['overflow-y'] =

Currently, you're fetching .style.overflow and subtracting y (as with numbers), which does not make sense here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜