To work with the jquery you need to
take the refrence of Jquery into your HTML code like below.
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<select name="garden" multiple="multiple" style="width: 100px; height: 200px">
<option>Bob</option>
<option selected="selected">Eric</option>
<option>Danny</option>
<option selected="selected">Arran</option>
<option>Soni</option>
<option>Ali</option>
<option>Ani</option>
<option>Rohan</option>
<option>Ram</option>
</select>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
div
{
color: Green;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<h1>
List Box selection</h1>
<select name="garden" multiple="multiple" style="width: 100px; height: 200px">
<option>Bob</option>
<option selected="selected">Eric</option>
<option>Danny</option>
<option selected="selected">Arran</option>
<option>Soni</option>
<option>Ali</option>
<option>Ani</option>
<option>Rohan</option>
<option>Ram</option>
</select> <br />
<b>Selected Text :</b>
<div>
</div>
<script>
$("select")
.change(function () {
var str = "";
$("select
option:selected").each(function () {
str += $(this).text() + ", ";
});
$("div").text(str);
})
.trigger("change");
</script>
</body>
</html>
No comments:
Post a Comment