HTML
<input type='text' id='searchable'value='hello world' />
<input type='hidden' id=x value='hel' />
我如何从#searchable 中选择文本,从隐藏输入值的末尾到#searchable 的末尾?
已修复 谢谢大家
$('input.complete').live('keyup.autocomplete', function(){
var hi=$(this).val().toUpperCase();
var was=this;//PROBlEM was here... was=$(this)
$(this).autocomplete({
source: function(request, response) {
$.ajax({ url: '<?=base_url()?>ajax/ac',
data: { 'term': this.term,'page': 'clinic','key': this.element.attr('data-complete')},
dataType: "json",
type: "POST",
success: function(data){
if(!data.length){
var result = [{label: 'No match found',value: response.term}];
response(result);
}else{
response(data);
$(was).val(data[0]['value']);
was.selectionStart=hi.length;
was.selectionEnd=data[0]['value'].length;
}
}
});
},
select: function(event, ui){},
minLength: 2,
});
});