Using javascript, I have taken data from a JSON file and placed it into an HTML select element. Each item from the JSON file is in a different option element within the select.
I would like to now be able to display a user's selected option in an HTML input element. I thought that this would work using this code:
<script>
$( "select" )
.change(function() {
var str = "";
$( "select option:selected" ).each(function() {
str += $( this ).text() + " ";
});
$( "div" ).text( str );
})
.trigger( "change" );
</script>
I think my issue is that my HTML generated from the javascript is not recognized. Is there a way I can make this work?
Thanks