我正在尝试修改this jQuery plugin,我希望在从文本框中选择后限制文本框中显示的总元素。我目前正在将所选项目移动到div,只有当您点击链接时才能看到该div。
这就是我所获得的:
countCities++; if(countCities > 2){
gonningToAppend = $('ul.chzn-choices li:visible').first().attr('id');
cityName = $('ul.chzn-choices li:visible span').first().html();
//alert(cityName);
$('#invisibleCityContainer').append('<div class="'+gonningToAppend+' search-choice-todel'+'"><div style="display:inline-block;">'+cityName+'</div></div>');
$('#invisibleCityContainer').append('<div id="'+gonningToAppend+'_close" class="x_button_for_city_list" ></div>');
//$('ul.chzn-choices li:visible').first().appendTo("#invisibleCityContainer");
$('ul.chzn-choices li:visible').first().hide();
$('#pluseCityCountInProfilePageEdit').html('and '+(countCities-2)+' more.');
}
$( "#pluseCityCountInProfilePageEdit" ).click(function() {
$("#invisibleCityContainer").animate( { "opacity": "show"} , 1000 );
event.stopPropagation();
}
);
HTML
<div id="invisibleCityContainer" style="display:none;" ></div>
我想要实现的目标: