Working with select tag and option in HTML using JQuery

JQuery made it really simple working with HTML select control. Consider you have following select control and you want to do various operations as listed thereafter. <select id="selectCtrl" multiple="multiple"> <option value="bb">Black Berry</option> </select> The attribute multiple=“multiple” will make this select as multi select. 1. How to add a new option to a HTML select control $('#selectCtrl').append('<option value="ga">Green Apple</option>'); $('#selectCtrl').append('<option value="ym">Yellow Mango</option>'); 2. How to get all the selected option ids from a HTML select control var selectedIds = $('#selectCtrl').