The first in this case, although the second will be better, but currently it has a different effect (the element moves every time).
Create it once and .clone()add it, for example:
var item = $('<div />', { 'class': 'ui-widget-content ui-state-default' })
.hover(function(){$(this).addClass('ui-state-hover')},
function(){$(this).removeClass('ui-state-hover');});
$(obj).children('option').each(function(){
$(list).append(item.clone(true).html(this.text).append(plus));
});
Here you can try here .
.text <option> , , , - .
, .delegate(), mouseneter mouseleave:
$(list).delegate("div", "mouseenter mouseleave", function() {
$(this).toggleClass('ui-state-hover');
});
var item = $('<div />', { 'class': 'ui-widget-content ui-state-default' });
$(obj).children('option').each(function(){
$(list).append(item.clone().html(this.text).append(plus));
});
.