javascript - How to tell if html element is manually selected or default -
javascript - How to tell if html element is manually selected or default -
in set of options can determine if selected value manually set vs defaulting using javascript (i can't modify html since i'm using build in framework functionality).
<select> <option value="a">a</option> <option value="b">b</option> <select> should distinguishable
<select> <option value="a" selected="selected">a</option> <option value="b">b</option> <select> even though both have selected.
javascript run on page load. need tell if html sent server selected , if not set selectedindex = -1
using onchange event can flag user has selected it.
var selection = document.getelementbyid('selection'); selection.onchange = function(){ user_selected = true; } with markup this:
<select id="selection"> <option value="a">a</option> <option value="b">b</option> <select> here's fiddle...
javascript jquery html
Comments
Post a Comment