JQuery Interview Questions

1. How to get value and text of a selected element from Dropdown by jQuery ? Ans: value=$(‘#selectid option:selected’).val(); text=$(‘#selectid option:selected’).text(); e.g. <select id=”myselect”> <option value=”1″>Label 1</option> <option value=”2″ selected=”selected”>Label 2</option> <option value=”3″>Label 3</option> </select> […]