javascript - IE problem with optgroup / option onclick event -
this doesn't work ie7. know work around?
<select> <optgroup label="swedish cars"> <option value="volvo">volvo</option> <option value="saab">saab</option> </optgroup> <optgroup label="german cars"> <option value="mercedes" onclick="alert(1);">mercedes</option> <option value="audi">audi</option> </optgroup> </select>
when pick mercedes, can see alert box. doesn't happen in ie.
try this
<select onclick="myalert(this.value)"> <optgroup label="swedish cars"> <option value="volvo">volvo</option> <option value="saab">saab</option> </optgroup> <optgroup label="german cars"> <option value="mercedes">mercedes</option> <option value="audi">audi</option> </optgroup> </select> <script> function myalert(value) { switch(value) { case "mercedes": alert(1); break; } } </script>
Comments
Post a Comment