I want to add a drop down to select cities but don\'t know how to select a default value before selection. I am using Bootstrap 3.
Here is the HTML Markup:
You have to add following code after your js code
$(".dropdown-menu li a")[2].click();
For example:
/* City Selection DropDown */
$(document).ready(function(){
$(".dropdown-menu li a").click(function(){
var selText = $(this).text();
$(this).parents('.btn-group').find('.dropdown-toggle').html(selText+' <span class="caret"></span>');
});
$(".dropdown-menu li a")[2].click();
});
You can put any array value instead of 2.