私は拡大している検索ボックスを作成していますが、フォーカスが入っているときはフォーカスが外れて拡大縮小しますが、自分のページには多くのボタン、テキストボックス、ラジオボタンがあります。拡大縮小する。 $('input')
で多くの入力でjQueryコードが適用されていますが、目的の入力(検索ボックス)にのみ必要ですか?
The code I am using:
<script type="text/javascript" src="for admg/jquery-latest.min.js"></script>
<script type="text/javascript">
//global vars
var inputWdith = '150px';
var inputWdithReturn = '100px';
$(document).ready(function() {
$('input').focus(function() {
//clear the text in the box.
// $(this).val(function() {
// $(this).val('');
// });
//animate the box
$(this).animate({
width: inputWdith
}, 500)
});
$('input').blur(function() {
$(this).val(' Search ');
$(this).animate({
width: inputWdithReturn
}, 800)
});
});
</script>
ホープ:
は正しい選択ではこのようなものになるだろうか?すべてのフォーカスで検索値がクリアされていることを認識していますか?私はそれが好きではない。 – daryl
しかし、私は次のコードのコメントを外すしようとする$(this).val(function(){// $(this).val( ''); //});検索ボックスに表示されるのは次のようなものです: "function(){"とあなたからの解決を感謝します。ありがとうございました –