I have a simple drop down list with values. On change, the value is passed to a variable place
The place
value is passed to a div, which loads data from an api. It works fines after I select one of the values, but my initial value is blank.
How can I store a default value before the select list is clicked?
<select name="places">
<option value="135264023">New York</option>
<option value="116721348">Los Angeles</option>
<option value="104279908">Dubai</option>
</select>
<div id="widget"></div>
<script>
$('select').change(function() {
var place = $(this).val();
console.log(place);
// This call have to happen after div and <script> tag.
widgetOptions({
element: 'widget',
placeId: place,
});
});
</script>