document.getElementById('if-font').innerHTML ='
<a href="http://example.com/?city='** accesskey **'">
http://example.com/?city='+cityName+'</a>';
<select name="citySelect" id="citySelect" onchange="selectChanged()" >
<option selected>Please Select</option>
<option value="xml/16702.xml" accessKey ="ZZZX">ZZZZ</option>
如何获得js代码的选项accesskey值?
我需要显示该链接
http://example.com/?city=ZZZX
答案 0 :(得分:0)
var accessKey = document.querySelector('option[value="xml/16702.xml"]')
.getAttribute("accessKey");
应该可以正常工作。
答案 1 :(得分:0)
就是这样:))
var selected = document.getElementById("citySelect").value;
var e = document.getElementById("citySelect");
sehir = e.options[e.selectedIndex].accessKey;