怎樣用javascript 來讀取selected option 的custom attribute ?

提示: 作者被禁止或刪除 內容自動屏蔽

$('select#id option:selected').val();

this ok?

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

  1. useraccount.selectedOptions[0].getAttribute('email')
複製代碼

TOP

回復 3# adrianmak

just translate the jquery code to javascript

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

研究了很久總算ok有無辦法一句過呢?
adrianmak 發表於 2013-8-17 18:33


你要一句過只有jQuery or 其他library
傳統javascript就是要那麼長~

TOP

  1. with(document.getElementById('useraccount'))var email = options[selectedIndex].getAttribute('email');
複製代碼
唔知算唔算一句
不過就算係都唔建議用with (雖然我好鍾意用

TOP

var email = document.getElementById('useraccount').options[document.getElementById('useraccount').selectedIndex].getAttribute('email');


點解有jQuery/Zepto唔用?

TOP