Javascript - innerHTML not working with HTML select menus

后端 未结 8 1436
眼角桃花
眼角桃花 2020-11-30 15:18

In my HTML page I have 2 select menus with IDs \"month\" and \"day\" - \"day\" is empty when the page loads, \"month\" has 12 options with values 1-12 corresponding to Janua

8条回答
  •  忘掉有多难
    2020-11-30 15:42

    This is a bit of a hack but it's tiny and works in both FF and IE as a workaround to IE's inability to change innerHTML on select elements.

    function swapInnerHTML(objID,newHTML) {
      var el=document.getElementById(objID);
      el.outerHTML=el.outerHTML.replace(el.innerHTML+'',newHTML+'');
    }
    

提交回复
热议问题