I’m trying to tweak a bit jquery.chosen by harvesthq (
I was lightly editing his plugin when I met this line
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
I can’t figure what is doing the last part of it specially
$('<div/>')
makes no sense for me.
I assume it’s a way to convert or protect the chars entered in search_field, but didn’t find anything like this before.
Can someone explain it?
$('<div/>')simply creates a new<div></div>element, which harvestq then fills with the search query, leaving you with:You can read about jQuery’s element creation in the docs