work as written.
You need to select the child nodes that are <option>'s, See the
selector below.
You also need to move the result write after the end of the loop.
<html>
<head>
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
</head>
<body>
<select id="select1" name="select1" multiple="multiple">
<option>Flowers</option>
<option>Shrubs</option>
<option>Trees</option>
</select>
<p/>
</body>
<script type="text/javascript">
<!--
$( function()
{
var str = "";
$("#select1>option").each(function(){
str += $(this).val() + ";";
});
$("p").text(str);
} );
//-->
</script>
</html>
No comments:
Post a Comment