ホバーすると入力テキスト検索ボックスが表示される検索アイコンがあります。jQuery を使用して入力にクラスを追加し、検索アイコンをホバーしたときにテキスト ボックスを表示します。それはうまくいっています。
次の機能は、ユーザーが検索ボックスやページの他の場所をクリックしないことにした場合、検索ボックスが消えることです。それもうまくいっています。
唯一残っている問題は、ユーザーが検索ボックスをクリックすると、それも消えてしまうことです。
私のHTML:
<input type="text" class="form-text text-hidden" title="Enter the terms you wish to search for." value="" size="15" id="edit-search-block-form-1" name="search_block_form" maxlength="128">
<input type="image" src="http://d3j5vwomefv46c.cloudfront.net/photos/large/802431483.png?1377197793" class="form-submit search-hover" alt="Search" id="edit-submit">
私のjQuery:
$(".search-hover").hover(function () {
$('.text-hidden').addClass('hover');
});
// Now remove the class in case of a false start or the user decides to do something else.
$("body:not(.text-hidden)").click(function(){
//alert('The body click is working!!!');
$('.form-text.text-hidden').removeClass('hover');
});
:not
セレクターを使用しhover
て、検索ボックス以外の場所をクリックした場合にのみクラスを削除することを示しようとしていますが、機能していないことに注意してください。