The while()
loops executes a code as long as a condition is True. If the condition starts out as false, the statements won’t execute at all.
while(condition){ //code to be executed }Example:
<script> var i =0; while(i<5){ document.write('<br /> i = '+i); i++; } </script>
The do...while()
loop is a variant of the while()
loop. First it is executed the block of code, and then it will repeat the loop as long as the specified condition is true.
do { //code to be executed } while(condition)Here is a simple example:
<script> var x = 8; do { document.write('<br> x = '+x); x++; } while(x<5) </script>
<ul> <li>http://coursesweb.net/html/</li> <li>http://coursesweb.net/css/</li> </ul>
.some_class { display: list-item; }
var obj = { "courses": ["php", "javascript", "ajax"] }; var jsonstr = JSON.stringify(obj); alert(jsonstr); // {"courses":["php","javascript","ajax"]}
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>'; $dochtml = new DOMDocument(); $dochtml->loadHTML($strhtml); $elm = $dochtml->getElementById("dv1"); echo $elm->nodeValue; // CoursesWeb.net