Possible Duplicate:
What's the difference between $(this) and this in jQuery?
In jquery selector, the example code is:
<body>
<select name="garden" multiple="multiple">
<option>Flowers</option>
<option selected="selected">Shrubs</option>
<option>Trees</option>
<option selected="selected">Bushes</option>
<option>Grass</option>
<option>Dirt</option>
</select>
<div></div>
<script>
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + " "; // I interested it this line
});
$("div").text(str);
})
.trigger('change');
</script>
</body>
In the example code, there is a portion of code:
str += $(this).text() + " ";
I am wondering, why here does not use str += this.text() + " ";
? In another word, why not use this
but use $(this)
in that portion of code? what is the difference between this
and $(this)
in this circumstance?