我已經開發jquery json autoxcomplete搜索那裏我想結束空間時結果來臨。目前,當我搜索somthing放置太空infront它不會給任何結果。請諮詢我如何添加thsi選項工作如何在jquery自動填充上跳過空格?
jQuery.extend(jQuery.ui.autocomplete.prototype, {
_renderItem: function(ul, item) {
var term = this.element.val(),
regex = new RegExp('(' + term + ')', 'gi');
html = item.label.replace(regex , "<b>$&</b>");
return jQuery("<li></li>")
.data("item.autocomplete", item)
.append(jQuery("<a></a>").html(html))
.appendTo(ul);
}
});
jQuery.noConflict();
jQuery(function(){
jQuery("#searchr").autocomplete({
source:'<?php echo JURI::root().'modules/mod_jomdirectory_search/tmpl/religious.php'; ?>',
minLength:1
});
});
的http://計算器。 com/questions/498970/how-do-i-trim-a-string-in-javascript – Colandus
@Colandus:謝謝,btw如何修正中間空格,如果某人搜索「tem ple」sti l自動完成工作。請諮詢 – fdz
@s_fdo這應該做到這一點http://stackoverflow.com/questions/6623231/remove-all-white-spaces-from-text – RossG