Javascript Running on JSFiddle but not on a webpage

后端 未结 6 2061
灰色年华
灰色年华 2021-01-26 12:18

Ok so I have a code that would show different forms based on dropdown selection
Here\'s the fiddle to that..

Well its always giving me Test1 which means its not cha

6条回答
  •  佛祖请我去吃肉
    2021-01-26 13:06

    The page is loaded into the DOM from the top down.

    Your document.getElementById('options').onchange is being called before the element with id options exists in the DOM.

    If you put your script below the divs, it'll work because the divs are now there before the script is called.

提交回复
热议问题