GetElementById giving ReferenceError in Chrome
GetElementById giving ReferenceError in Chrome
我不知道发生了什么,因为我从来没有遇到过JS的问题,但我们开始吧。我一直得到一个未捕获的参考错误在Chrome与此代码:
function showShareButtons() {
var buttons = getElementById("sharebtns");
document.buttons.style.visibility = 'visible';
}
谁能告诉我怎么了?谢谢! 您不能简单地为变量声明getElementById
本身。您需要使用document.getElementById
:
function showShareButtons() {
var buttons = document.getElementById("sharebtns");
buttons.style.visibility = 'visible';
}
即使你最终在你的代码中使用文档,它也不会是相同的,因为变量不能被声明为任何明确的东西。
document.getElementById("sharebtns");
应该是这样的:function showShareButtons() {
var buttons = document.getElementById("sharebtns");
buttons.style.visibility = 'visible';
}
相关文章:
- window.opener not working in chrome & IE
- cmd+c in keyUp event on Chrome OSX (Mac)
- requestAnimFrame 60FPS in Chrome, 1FPS in FF
- history.pushState in Chrome make favicon request
- jquery append in chrome
- javascript self.close() in chrome
- XMLHTTPRequest resulting in Aw, snap in chrome
- Canvas Bug in Chrome
- ERR_NAME_NOT_RESOLVED in Chrome
- document.getElementById().value return undefined in chrome
- window.find() in Firefox vs Chrome
- event.dataTransfer.dropEffect in chrome
- net::ERR CONTENT LENGTH MISMATCH in Chrome with Jboss WildFl
- window.open as tabs not pop ups in Chrome
- Firefox Bookmarklet in Chrome
- Ruby Time to JavaScript Date in Chrome/Firefox
- Using onafterprint in Chrome & Safari
- Chrome Crashing with whitespaces in Textarea on using onClic
- Weird behavior in chrome's javascript .width property
- document.getElementById in chrome