selectedOptions[0].textContent; not working in IE or Firefox

前端 未结 2 1496
Happy的楠姐
Happy的楠姐 2021-01-07 18:06
function call(op) {
    var x = op.selectedOptions[0].textContent;
    var n = x.substring(0, 3);
    //alert(n);
    document.pts.inputbox.value = n;
    document.p         


        
2条回答
  •  滥情空心
    2021-01-07 18:59

    Try this

    function call(op) {
        var x = op.options[op.selectedIndex].text;
        var n = x.substring(0, 3);
        alert('Index : '+op.selectedIndex+' and first 3 lettrs are : '+n);
    }
    

    DEMO.

提交回复
热议问题