My HTML Code:
<select id="select">
<option value="Select" selected >Select</option>
<option value="lahore" id="lahore" >Lahore</option>
<option value="karachi" id="karachi">Karachi</option>
</select>
<label> <input class="chkbox" type="checkbox" name="" id="chkbox-lahore" value="Lahore">Lahore</label>
<label> <input class="chkbox" type="checkbox" name="" id="chkbox-karachi" value="Karachi">Karachi</label>
JQuery Code:
$("#select").change(function(){
var selected=$(this).val();
$(’[id^=“chkbox-”]’).prop(‘checked’, false);
$("#chkbox-"+selected).prop(‘checked’, true);
});
Code is working fine, since I have just taken it from the google I want to understand what this bold text is actually doing, thanks! Any links to understand this especially what ^ symbol means and - sign after chkbox
Moreover, I have used chkbox class for my checkbox input type not id and to specify it in jQuery we use .chkbox but here it not works, when I write .chkbox Here $(".chkbox-"+selected).prop(‘checked’, true);