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

質問編集履歴

4

説明とhtmlタグを追記しました

2019/01/15 06:40

投稿

mei666
mei666

スコア15

title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,9 @@
2
2
  ページ内の一覧から、キーワード検索できるようにInputboxを設置しております。
3
3
  現在は、1つのキーワードで検索できます↓が、複数のキーワードで検索できるようにしたいのですが、どうなおしたらいいのか、わかりません。
4
4
  jQueryは素人です。
5
+ 例ですが、inputboxに「1 a」で検索をかけると1行目のみ表示したいのです。
6
+ 今の記述だと1つのワードしか検索かけられません。
7
+ アドバイスいただけると助かります!
5
8
 
6
9
  ```jQuery
7
10
  jQuery$(function() { 
@@ -28,4 +31,11 @@
28
31
  <input type="text" id="search">
29
32
  <input type="button" value="絞り込む" id="button">
30
33
  <input type="button" value="すべて表示" id="button2">
34
+
35
+ <table id="result"><tbody>
36
+ <tr><td>123</td><td>abc</td></tr>
37
+ <tr><td>456</td><td>ddd</td></tr>
38
+ <tr><td>456</td><td>aaa</td></tr>
39
+ <tr><td>123</td><td>ccc</td></tr>
40
+ </tbody></table>
31
41
  ```

3

修正しました

2019/01/15 06:40

投稿

mei666
mei666

スコア15

title CHANGED
File without changes
body CHANGED
@@ -4,24 +4,25 @@
4
4
  jQueryは素人です。
5
5
 
6
6
  ```jQuery
7
- $(function(){
7
+ jQuery$(function() { 
8
-  $('#button').on("click",function(){
8
+ $('#button').on("click", function() {  
9
-    var re = new RegExp($('#search').val());
9
+ var re = new RegExp($('#search').val());   
10
-    $('#result tbody tr').each(function(){
10
+ $('#result tbody tr').each(function() {    
11
-      var tr = $(this);
11
+ var tr = $(this);    
12
-     tr.hide();
12
+ tr.hide();     
13
-       $('td', this).each(function(){
13
+ $('td', this).each(function() {      
14
-       var txt = $(this).html();
14
+ var txt = $(this).html();      
15
-        if(txt.match(re) != null){
15
+ if (txt.match(re) != null) {       
16
-        tr.show();
16
+ tr.show();     
17
-      }
17
+ }    
18
-      });
18
+ });   
19
-     });
19
+ });  
20
-   });
20
+ });
21
- $('#button2').on("click",function(){
21
+ $('#button2').on("click", function() { 
22
-   $('#result tr').show();
22
+ $('#result tr').show(); 
23
-   });
23
+ });
24
- });
24
+ });
25
+
25
26
  ```
26
27
  ```html
27
28
  <input type="text" id="search">

2

functionがきれていたので修正しました

2019/01/15 06:14

投稿

mei666
mei666

スコア15

title CHANGED
File without changes
body CHANGED
@@ -4,7 +4,7 @@
4
4
  jQueryは素人です。
5
5
 
6
6
  ```jQuery
7
- $(func tion(){
7
+ $(function(){
8
8
   $('#button').on("click",function(){
9
9
     var re = new RegExp($('#search').val());
10
10
     $('#result tbody tr').each(function(){

1

インデントを修正してみましたが、すみません。素人なので醜いかもしれません。

2019/01/15 06:12

投稿

mei666
mei666

スコア15

title CHANGED
File without changes
body CHANGED
@@ -1,31 +1,30 @@
1
1
  社内サーバー(Webサーバーではない)にHTMLを作成しています。
2
2
  ページ内の一覧から、キーワード検索できるようにInputboxを設置しております。
3
3
  現在は、1つのキーワードで検索できます↓が、複数のキーワードで検索できるようにしたいのですが、どうなおしたらいいのか、わかりません。
4
- jjj
5
- Jsファイル
4
+ jQueryは素人です。
5
+
6
- ```ここに言語を入力
6
+ ```jQuery
7
7
  $(func tion(){
8
- $('#button').on("click",function(){
8
+  $('#button').on("click",function(){
9
- var re = new RegExp($('#search').val());
9
+    var re = new RegExp($('#search').val());
10
- $('#result tbody tr').each(function(){
10
+    $('#result tbody tr').each(function(){
11
- var tr = $(this);
11
+      var tr = $(this);
12
- tr.hide();
12
+     tr.hide();
13
- $('td', this).each(function(){
13
+       $('td', this).each(function(){
14
- var txt = $(this).html();
14
+       var txt = $(this).html();
15
- if(txt.match(re) != null){
15
+        if(txt.match(re) != null){
16
- tr.show();
16
+        tr.show();
17
- }
17
+      }
18
- });
18
+      });
19
- });
19
+     });
20
- });
20
+   });
21
21
  $('#button2').on("click",function(){
22
- $('#result tr').show();
22
+   $('#result tr').show();
23
+   });
23
24
  });
24
- });
25
-
26
25
  ```
27
- html記述
26
+ ```html
28
- ```ここに言語を入力
27
+ <input type="text" id="search">
29
- <input type="text" id="search" onkeydown=go"();"> <input type="button"
28
+ <input type="button" value="絞り込む" id="button">
30
- value="絞り込む" id="button"> <input type="button" value="すべて表示" id="button2">
29
+ <input type="button" value="すべて表示" id="button2">
31
30
  ```