0
PHPファイルの結果をHTML divに解析するjQuery検索スクリプトがあります。私はアクティブなクエリがないときに検索ボックスを自動的に選択し、アクティブなクエリがあるときは選択しないようにしたい。これどうやってするの?あなたが私の質問を理解できることを願っています。jQueryでテキストボックスが自動的に選択される
私のjQueryの検索スクリプトは次のとおりです。内部(下にこれを追加します。
$(document).ready(function(){
$('[id^=type_]').click(function(){
type=this.id.replace('type_','');
$('[id^=type_]').removeClass('selected');
$('#type_'+type).addClass('selected');
return false;
});
$('#type_search').click();
$('#query').keyup(function(){
var query=$(this).val();
var url='/'+type+'/'+query+'/';
window.location.hash=''+type+'/'+query+'/';
document.title=$(this).val()+' - My Search';
$('#results').show();
if(query==''){
window.location.hash='';
document.title='My Search';
$('#results').hide();
}
$.ajax({
type:'GET',
url:url,
dataType:'html',
success:function(results){
$('#results').html(results);
}
});
});
if(window.location.hash.indexOf('#'+type+'/')==0){
query=window.location.hash.replace('#'+type+'/','').replace('/','');
$('#query').val(decodeURIComponent(query)).keyup();
}
});
あなたのコメントリクエストごとに
$(document).ready
機能の – AlienWebguy