The answer to your IT questions
 

Advanced search  • Search tips
My QUESTIONS & ANSWERS
 Question:

How to find which is the biggest value?

User Asked by: alexander
Published on: 14:23/18.06.2008
Status: OPEN

<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>
 Answers: 1
Sort by: /\ date | rating
Image Answer by: xpert
Posted on: 14:23/18.06.2008
Rating: 1 from possible 5 with 1 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
  
| Home | Hall of fame | Register | Log in | Terms of service | Help | Contacts |