Find width max width of a div and assign the width to all div's
Dear Sir
I am using following code to display 'Period'
Being dynamic (creading using do while loop of php using MYSQL database)
, i dont know the width of the same
I want to assign the max width of the div to all DIV's having class 'period
- <div style=" font-family: 'Arial', sans-serif; font-size:16px; color:#fff; font-weight:bold; background-color:#006699; width:100%; id='<?php echo 'period'.$rows['id'];?> "; class="period" ><?php echo $rows['period'];?></div>
I tried
- $(document).ready(function() {
-
- var maxWidth=0;
- $('.bigsaleperiod').each(function() {
- maxWidth = Math.max(maxWidth, $(this).width());
-
- }).width(maxWidth);
-
-
- var maximgWidth1=0;
-
- $("[id^=period]").each(function() {
- maximgWidth1 = Math.max(maximgWidth1, $(this).width());
-
-
- }).width(maximgWidth1);
- });
What's wrong with the code ?
I had changes following working code for height .....just changes height to width
- var maxHeight=0;
- $('.team').each(function() {
- maxHeight = Math.max(maxHeight, $(this).height());
-
- }).height(maxHeight);
- });
-
- var maximgHeight1=0;
-
- $("[id^=team]").each(function() {
- maximgHeight1 = Math.max(maximgHeight1, $(this).height());
-
-
- }).height(maximgHeight1);