Use created attribute with javascript in select list

前端 未结 1 824
礼貌的吻别
礼貌的吻别 2021-01-24 01:22

im trying to access an attribute that i created in a select list.



        
相关标签:
1条回答
  • 2021-01-24 01:58

    Try this:

    var newUrl = document.getElementById('test').getAttribute('car');
    

    EDIT

    For the <select>, you have to look into the selected <option> element, not the <select> itself:

    var select = document.getElementById('test');
    select.options[select.selectedIndex].getAttribute('car');
    
    0 讨论(0)
提交回复
热议问题