teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

誤字

2020/06/03 02:44

投稿

todayyy
todayyy

スコア31

title CHANGED
File without changes
body CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
  <div id="search">
15
- <ons-search-input placeholder="ons-search-input" type="search" id="form1">
15
+ <ons-search-input placeholder="ons-search-input" id="form1">
16
16
  <input type="search" class="search-input" placeholder="ons-search-input" id="text1">
17
17
  </ons-search-input>
18
18
  </div>

1

文字の修正

2020/06/03 02:44

投稿

todayyy
todayyy

スコア31

title CHANGED
File without changes
body CHANGED
@@ -12,8 +12,8 @@
12
12
 
13
13
 
14
14
  <div id="search">
15
- <ons-search-input placeholder="ons-search-input" type="search">
15
+ <ons-search-input placeholder="ons-search-input" type="search" id="form1">
16
- <input type="search" class="search-input" placeholder="ons-search-input">
16
+ <input type="search" class="search-input" placeholder="ons-search-input" id="text1">
17
17
  </ons-search-input>
18
18
  </div>
19
19
 
@@ -26,6 +26,21 @@
26
26
  </ons-template>
27
27
  ```
28
28
 
29
+ ```javascript
30
+ document.addEventListener('init',function(event){
31
+ if(event.target.matches('#Search_page')){
32
+
33
+ var form = document.getElementById('form1');
34
+ form.addEventListener("change" , function(event){
35
+
36
+ var a = document.getElementById('text1').value;
37
+ alert(a);
38
+
39
+ });
40
+ }
41
+ });
42
+ ```
43
+
29
44
  ons-search-inputを使用せずformでonsubmit(function()return false;)を使用することもできるのですが、ons-search-inputのonchangeのほうが使い勝手が個人的には良いと思いましたので投稿させていただきました。
30
45
  Androidのほうでは正常に検索ボタンとして表示されていることが確認できています。
31
46
  ご回答よろしくお願いします。