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

質問編集履歴

2

javascriptの編集

2020/02/11 08:14

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -25,9 +25,9 @@
25
25
  ```
26
26
 
27
27
  ```javascript
28
- var biggestWidth = $(".sec__bg").width();
28
+ var biggestWidth = $(".area").width();
29
29
  var array1 = [];
30
- $('.box').each(function(i){
30
+ $('.contents').each(function(i){
31
31
  var boxWidth = $(this).width() + (i + 1);
32
32
  array1.push(boxWidth);
33
33
  });

1

javascriptの編集

2020/02/11 08:14

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -25,17 +25,18 @@
25
25
  ```
26
26
 
27
27
  ```javascript
28
- $(function(){
29
- $(window).on('load resize', function() {
30
- var biggestWidth = $(".pic").width();
28
+ var biggestWidth = $(".sec__bg").width();
29
+ var array1 = [];
31
- $(".contents").each(function(){
30
+ $('.box').each(function(i){
32
- if ($(this).width() > biggestWidth ) {
33
- biggestWidth = $(this).width()
31
+ var boxWidth = $(this).width() + (i + 1);
32
+ array1.push(boxWidth);
33
+ });
34
+ console.log(array1);
35
+
36
+ $.each(array1, function(index, elem){
37
+ if(elem > biggestWidth){
38
+ biggestWidth = elem;
34
- }
39
+ }
40
+ console.log(biggestWidth);
35
- });
41
+ });
36
- $(".area").each(function(){
37
- $(this).width(biggestWidth);
38
- });
39
- })
40
- })
41
42
  ```