javascript - Set Evenet Listener on Selectobox is disabled(DOMAttrModified) -
i set event listener on selectbox should triggerd while attribute changed disabled. tryed following:
<select id="a"> <option>heino</option> <option>michael jackson</option> <option>tom waits</option> <option>nina hagen</option> <option>marianne rosenberg</option> </select> <button id="b">action</button> <script type="text/javascript"> var = document.getelementbyid("a"); a.addeventlistener('domattrmodified', function() { alert(0); }, false); var b = document.getelementbyid("b"); b.onclick = function() { a.setattribute('disabled', 'disabled'); }; </script>
by changing disabled attribute attribute example working fine. have idea trigger event? solution browsers nice.
thanks
with a.setattribute('disabled', 'disabled')
disable <select>
, not specific <option>
. if want disable selected option if click button:
var b = document.getelementbyid("b"); b.onclick = function () { (var = 0; < a.length; += 1) { if (a[i].selected == true) { a[i].setattribute('disabled', 'disabled'); } } };
Comments
Post a Comment