わかりました、私はあなたの現在のソースコードとそれに問題があることを伝える答えを見ていませんあなたが私のコメントを認めているようには見えないので、あなたは働くスニペットが行うことをあなたに示しているかもしれません。
を変更する必要がある唯一のものは、あなたのセレクタ'input[type="search"]'
に一致するか、入力タイプ'input[type="text"]'
に一致するように、あなたのセレクタを変更するにはtext
からsearch
にtype
属性です。
変更入力type
= 検索
document.querySelector('input[type="search"]').id = 'sinput';
document.getElementById("sinput").addEventListener("keypress", function() {
document.getElementById("1").style.display ="none";
});
<div id="1">hey all</div>
<input type="search" name="txt" />
または変更セレクタinput[type="
TEXご質問があれば、T"]
document.querySelector('input[type="text"]').id = 'sinput';
document.getElementById("sinput").addEventListener("keypress", function() {
document.getElementById("1").style.display ="none";
});
<div id="1">hey all</div>
<input type="text" name="txt" />
は、下記のコメントして自由に感じると私はできるだけ早くあなたに戻って取得します。
こちらがお役に立てば幸いです。ハッピーコーディング!
'' – nogad
あなたの入力タイプは 'text'ですが、セレクタに取得しようとしています'search' ... – NewToJS