[removed] style.display:'block' doesn't work

前端 未结 3 1698
猫巷女王i
猫巷女王i 2021-01-21 06:08

any idea why this JavaScript just shows \"block\" and not the content of the (hidden) DIV?




3条回答
  •  -上瘾入骨i
    2021-01-21 06:45

    This code describes your problem: http://jsbin.com/jigiy/1

    
    Show my DIV
    

    Why is this happening:

    Javascript setters return the value input, so document.getElementById('mydiv').style.display='block' will return 'block', which is equal to href="javascript:'block'". Now it refers to about:blank and sets its content to block.

    I'm not sure why the browsers refer and set the content of about:blank, but i think this has something to do with data-urls.

提交回复
热议问题