我有一个带有id="playerViewer"
.
在某些情况下,我想更改此 div 的样式,我尝试这样做:
if (include(urlarr, listen)) {
//$('#playerViewer').css('position', 'fixed').css('top', '5px').css('right', '100px'); I Don't want to use Jquery
document.getElementById("playerViewer").style.position="fixed";
document.getElementById("playerViewer").style.top="5px";
document.getElementById("playerViewer").style.right="100px";
alert("No alert showing up, even though the function is true");
};
在我的控制台中,我得到:
Uncaught TypeError: Cannot read property 'style' of null
所以我想我用getElementById
错了——有人能指出我正确的方向吗?
HTML:
<div id="playerViewer">
<div id="defaultVideocontainer">
<div id="defaultVideopart">
<video id='dago_video' class='jwplayer dago-video' width='480' height='360' controls ></video>
</div>
</div>
</div>