如题: 
普通标签自定义属性可以用;
<input type="text" id="tt" name="mm" value=""  outerAttribute="fdfdfdfdf" /><input type="text1" id="tt1" name="mm1" value=""/>
<script type="text/javascript">
document.getElementById("tt1").value=document.getElementById("tt").getAttribute("outerAttribute");
</script>那如果标签select中的option 自定义属性怎么提取:
                    <select name="select" id="select"  >
                     <option lrc="aa.lrc" >str1</option>
                     <option lrc="dd.lrc" >str2</option>
                    </select>
当str1记录被选择时怎么提取相应的"lrc"自定义属性呢?

解决方案 »

  1.   

    var select = document.getElementById('select');
    var lrc = select.item(select.selectedIndex).getAttribute('lrc');
      

  2.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <script   language="javascript">
     window.onload=function(){
     var obj=document.getElementById("select");
     var index=obj.selectedIndex;
     var text=obj.options[index].getAttribute("lrc");
     alert(text);
     }
      </script>
    </head>
    <body>
      <select name="select" id="select"  > 
                        <option lrc="aa.lrc" >str1 </option> 
                        <option lrc="dd.lrc" >str2 </option> 
                        </select> 
    </body>
    </html>