how to get option title="sample" using jquery
Posted
by tom
on Stack Overflow
See other posts from Stack Overflow
or by tom
Published on 2010-05-07T20:10:29Z
Indexed on
2010/05/07
20:18 UTC
Read the original article
Hit count: 178
Hi, I'm trying to update a hidden field based on the a title attribute on a select option, I've tried the code bellow and can't seem to get it to work. Thanks for any help!
<form>
<select id="selectbox">
<option name="test" value="one" title="title" selected="selected">one</option>
<option name="test2" value="two" title="title2">two</option>
</select>
</form>
<input id="update" type="hidden" value="defaultold" />
<script>
$('#update').val('default');
$('#selectbox').change(function() {
$('#update').val($(this).attr("title"));
});
</script>
© Stack Overflow or respective owner