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

質問編集履歴

3

誤字

2021/05/19 23:15

投稿

ttbdz
ttbdz

スコア2

title CHANGED
File without changes
body CHANGED
@@ -7,30 +7,7 @@
7
7
  ### 該当のソースコード
8
8
 
9
9
  ```jQuery
10
- <script>
10
+
11
- $(function() {
12
- $('.search__btn').on('click', function() {
13
- $('.lists').empty();
14
- var searchWord = $('.search__text__input').val();
15
- if(searchWord === '') {
16
- $('.lists').html('<p class="message">文字が入力されていません。</p>');
17
- return;
18
- };
19
- $.ajax({
20
- url: 'https://app.rakuten.co.jp/services/api/BooksTotal/Search/20130522',
21
- type: 'GET',
22
- datatype: 'json',
23
- data: {
24
- keyword: searchWord,
25
- applicationId: "",
26
- booksGenreId: '001',
27
- page: 1,
28
- hits: 20
29
- }
30
- }).done(function(data) {
31
- if(data.hits === 0) {
32
- $('.lists').html('<p class="message">検索結果がありませんでした。<br>別のキーワードで検索してください</p>');
33
- }
34
11
  data.Items.forEach(function(item) {//この部分で$.each(配列, function functionName() {})を使って書きたい。
35
12
  var template = '<li class="lists__item">' +
36
13
  '<div class="lists__item__inner">' +
@@ -44,12 +21,6 @@
44
21
  '</li>';
45
22
   $('.lists').append(template);
46
23
  })
47
- }).fail(function() {
48
- $('.lists').html('<p class="message">データ通信ができませんでした<br>接続を確認してください。</p>');
49
- });
50
- });
51
- });
52
- </script>
53
24
  ```
54
25
 
55
26
  ### 試したこと
@@ -68,194 +39,4 @@
68
39
  $('.lists').append(template);
69
40
  })
70
41
  ```
71
- という風に書いてみましたがうまく表示されませんでした。
42
+ という風に書いてみましたがうまく表示されませんでした。
72
- ### 補足情報(FW/ツールのバージョンなど)
73
- ```html
74
- <!doctype html>
75
- <html>
76
- <head>
77
- <meta charset="UTF-8">
78
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
79
- <meta name="format-detection" content="telephone=no">
80
- <title>jQuery</title>
81
- <link rel="stylesheet" href="../../common/css/reset.css">
82
- <link rel="stylesheet" href="../../common/css/base.css">
83
- <link rel="stylesheet" href="./css/style.css">
84
- </head>
85
- <body>
86
- <div class="wrap">
87
- <div class="container">
88
- <div class="header">
89
- <p class="header__title">Search Books!</p>
90
- </div>
91
- <div class="search">
92
- <div class="search__text">
93
- <input type="text" class="search__text__input" placeholder="検索する" data-js="search-word">
94
- </div>
95
- <button class="search__btn" data-js="search-btn">検索する</button>
96
- </div>
97
- <div class="message"></div>
98
- <ul class="lists"></ul>
99
- </div>
100
- </div>
101
- <script src="../../common/js/jquery.js"></script>
102
- <script src="./js/appid.js"></script>
103
- </body>
104
- </html>
105
- ```
106
- ```css
107
- .clearfix::after {
108
- display: block;
109
- clear: both;
110
- content: '';
111
- }
112
- .wrap {
113
- padding-bottom: 40px;
114
- }
115
- .header {
116
- width: 100%;
117
- background-color: #43cee0;
118
- }
119
- .header__title {
120
- line-height: 60px;
121
- text-align: center;
122
- font-size: 20px;
123
- color: #fff;
124
- }
125
- .search {
126
- overflow: hidden;
127
- margin-bottom: 50px;
128
- background: #fff;
129
- box-shadow: 0 1px 5px #ccc;
130
- }
131
- .search__text {
132
- width: 100%;
133
- }
134
- .search__text__input {
135
- -webkit-box-sizing: border-box;
136
- box-sizing: border-box;
137
- width: 100%;
138
- margin-bottom: 20px;
139
- padding: 0 10px;
140
- line-height: 3em;
141
- border-top: none;
142
- border-left: none;
143
- border-right: none;
144
- border-bottom: 1px solid #eee;
145
- font-size: 20px;
146
- }
147
- .search__btn {
148
- display: block;
149
- margin: 0 auto 20px;
150
- padding: 0 20px;
151
- line-height: 40px;
152
- border: none;
153
- font-size: 18px;
154
- color: #fff;
155
- background-color: #43cee0;
156
- cursor: pointer;
157
- }
158
- .search__btn:hover {
159
- background-color: #1eabbd;
160
- }
161
- .lists {
162
- overflow: hidden;
163
- margin-left: 20px;
164
-
165
- }
166
- .lists__item {
167
- -webkit-box-sizing: border-box;
168
- box-sizing: border-box;
169
- display: inline-block;
170
- width: 25%;
171
- padding: 0 20px 20px 0;
172
- vertical-align: top;
173
- text-align: center;
174
- }
175
- .lists__item__inner {
176
- width: 100%;
177
- max-width: 200px;
178
- margin: 0 auto;
179
- }
180
- .lists__item__link {
181
- display: block;
182
- text-decoration: none;
183
- }
184
- .lists__item__img {
185
- margin-bottom: 20px;
186
- width: 100%;
187
- max-width: 150px;
188
- -webkit-box-shadow: 0 1px 5px #ccc;
189
- box-shadow: 0 1px 5px #ccc;
190
- }
191
- .lists__item__detail {
192
- margin-bottom: 10px;
193
- padding-left: 5em;
194
- text-indent: -5em;
195
- line-height: 1.5em;
196
- text-align: left;
197
- font-size: 12px;
198
- }
199
- .message {
200
- margin-bottom: 50px;
201
- text-align: center;
202
- }
203
- .pager {
204
- border-top: 1px solid #ccc;
205
- padding-top: 35px;
206
- }
207
- .btn-wrapper {
208
- display: flex;
209
- justify-content: center;
210
- margin-top: 20px;
211
- }
212
- .btn-item {
213
- width: 80px;
214
- height: 40px;
215
- line-height: 40px;
216
- box-sizing: border-box;
217
- background-color: #43cee0;
218
- color: #fff;
219
- margin-left: 10px;
220
- display: block;
221
- font-size: 16px;
222
- text-align: center;
223
- }
224
- .btn-item:hover:not(.disabled) {
225
- background-color: #1eabbd;
226
- }
227
- .btn-item:first-child {
228
- margin-left: 0;
229
- }
230
- .disabled {
231
- background-color: #888;
232
- }
233
- .disabled.btn-item {
234
- cursor: default;
235
- }
236
- .counter {
237
- text-align: center;
238
- font-size: 20px;
239
- font-weight: bold;
240
- }
241
- .counter-current {
242
- margin-right: 10px;
243
- color: #43cee0;
244
- }
245
- .counter-all {
246
- margin-left: 10px;
247
- }
248
-
249
-
250
- @media screen and (max-width: 767px) {
251
- .lists__item {
252
- width: 33.33%;
253
- }
254
- }
255
-
256
- @media screen and (max-width: 479px) {
257
- .lists__item {
258
- width: 50%;
259
- }
260
- }
261
- ```

2

誤字

2021/05/19 23:15

投稿

ttbdz
ttbdz

スコア2

title CHANGED
File without changes
body CHANGED
@@ -96,11 +96,6 @@
96
96
  </div>
97
97
  <div class="message"></div>
98
98
  <ul class="lists"></ul>
99
- <div class="pager" data-js="pager">
100
- <div class="counter">
101
- <span class="counter-current"></span>/<span class="counter-all"></span>
102
- </div>
103
- </div>
104
99
  </div>
105
100
  </div>
106
101
  <script src="../../common/js/jquery.js"></script>

1

誤字

2021/05/19 13:16

投稿

ttbdz
ttbdz

スコア2

title CHANGED
File without changes
body CHANGED
@@ -22,7 +22,7 @@
22
22
  datatype: 'json',
23
23
  data: {
24
24
  keyword: searchWord,
25
- applicationId: appId,
25
+ applicationId: "",
26
26
  booksGenreId: '001',
27
27
  page: 1,
28
28
  hits: 20