Show selected option value in a div

HTML

 

<select id="keys">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>

<div id="example"></div>


JQuery

$(document).ready(function() {
$("#keys").change(function(){
$('#example').empty();
var selectedKey = $(this).val();
$('#example').append(selectedKey);
});
});

 

JQuery Library

https://code.jquery.com/jquery-1.7.2.js

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s