Get selected listitems using jquery

Madhuk
Posted by Madhuk under jQuery category on | Points: 40 | Views : 4025
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" >
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:ListBox>


<script type="text/javascript">
$(document).ready(function(){
$("#Button3").click(function(){
//gets the items without any seperater
//alert($("#ListBox1 :selected").text());
//$.map property iterates through the array values
var SelectedItems1 =$.map($('#DropDownList1 :selected'), function(e) { return $(e).text(); })
alert(SelectedItems1);
});
});
</script>

Comments or Responses

Login to post response