in Advanced 

Question preview

HomeQuestion preview:
Log in

How to find which is the biggest value?

<script type="text/javascript">
	function func()
	{
              var divs = document.getElementsByTagName('div');
              for(var i=0; i<divs.length; i++)
              {
                 if(divs[i].className.indexOf = 'some-class-name')
                 {
                      var heights = divs[i].offsetHeight;

                      /* How to find which is 
                          the biggest value for 'var heights' ? */
                 }
              }
	}
	window.onload = func;
</script>
Do you know someone who could answer? Ask him for help
Answers: 1
Sort by: date rating
image xpert
17:23/18.06.2008
1.7 from possible 5 with 3 votes
<script type="text/javascript">
	function func()
	{
              var maxVal=-1;
              var divs = document.getElementsByTagName('div');
              for(var i=0; i<divs.length; i++)
              {
                 if(divs[i].className.indexOf = 'some-class-name')
                 {
                      var heights = divs[i].offsetHeight;
                      if (heights >  maxVal) {
                            maxVal = heights;
                      }
                 }
              }
              if (maxVal ==-1) {
                  alert('For some reaon there is no max value.')
              } else {
                  alert('maxVal = ' + maxVal )
              }
	}
	window.onload = func;
</script>



Vote:
Please vote! Your opinion matters!
If you haven't found what you've looking for, post a question
Ask question
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |