Question

In: Computer Science

3. Every HTML element has innerHTML and outerHTML properties. What is the difference between the two?...

3. Every HTML element has innerHTML and outerHTML properties. What is the difference between the two?

4. Suppose a variable x holds “dog”. After the following code gets executed, what does x hold? x += "fish";

5. When the following code executes, what message does the dialog box display? var month = "January"; if (month.toLowerCase() == "january") { alert("It is " + month + "!"); }

6. After the following code executes, what does x hold? var animal = "porcupine"; var x = animal.lastIndexOf("p", 3);

7. What is the purpose of the z-index CSS property?

8. When executed, what does the following code fragment display? var x = 5; var y = x++; alert("x = " + ++x + ", y = " + y);

Solutions

Expert Solution

(3.) Difference between innerHTML & outerHTML:

innerHTML: It is a property of a DOM (DatavObject Model) element that represents the HTML data inside the element in between opening and closing tags.

outerHTML: It is a property of a DOM (DatavObject Model) element that represents the HTML data inside the element in between opening and closing tags as well as HTML data of the selected element.

Example:

<tr id="table_row">
    <td>FIRST</td>
    <td>SECOND</td>
</tr>

In this above example, innerHTML returns only <td> element, whereas outerHTML returns <tr> with <td> elements.

(4.)

var x = "dog";
x += "fish";
document.write(x);

Output:

(5.)

var month = "January";

if (month.toLowerCase() == "january"){
        alert("It is " + month + "!");
}

Output:

(6.)

var animal = "porcupine";
var x = animal.lastIndexOf("p", 3);
document.write(x)

Output:

(7.)

The main purpose of the z-index CSS property to sets the stacking level of an element. There are two types by which we can use z-index property: (1.) auto (2.) integer

Example:

<!DOCTYPE html>
<html>
   <head>
   </head>
   
   <body>
      <div style = "background-color:blue;
         width:200px;
         height:200px;
         position:relative;
         top:10px;
         left:80px;
         z-index:2">
      </div>
      
      <div style = "background-color:green;
         width:200px;
         height:200px;
         position:relative;
         top:-80px;
         left:35px;
         z-index:1;">
      </div>
   </body>
</html> 

Output 1:

<!DOCTYPE html>
<html>
   <head>
   </head>
   
   <body>
      <div style = "background-color:blue;
         width:200px;
         height:200px;
         position:relative;
         top:10px;
         left:80px;
         z-index:0">
      </div>
      
      <div style = "background-color:green;
         width:200px;
         height:200px;
         position:relative;
         top:-80px;
         left:35px;
         z-index:1;">
      </div>
   </body>
</html> 

Output 2:

(8.)

var x = 5;
var y = x++;
alert("x = " + ++x + ", y = " + y);

Output:

Thumbs Up Please !!!


Related Solutions

What is the difference between HTML attributes and CSS properties? What are depricted elements and how...
What is the difference between HTML attributes and CSS properties? What are depricted elements and how can we address them? Why would a browser not support certain fonts? 1 paragraph for each plz
What is the difference between an atom and an element? What are atoms composed of? What...
What is the difference between an atom and an element? What are atoms composed of? What is the significance of atomic number and mass number?
What is an element that shares group properties with Mg? What properties are common in this...
What is an element that shares group properties with Mg? What properties are common in this group?
What is meant by essentiality of plant nutrients? What is the difference between an essential element...
What is meant by essentiality of plant nutrients? What is the difference between an essential element and a beneficial element? Describe the steps you would go through in order to determine the essentiality or non-essentiality of an element for a higher plant. Can a plant nutritionist contribute to preventing malnutrition in human beings? Explain this statement with examples.                                   
What are the physical and chemical properties of matter. Explain what is the difference between extensive...
What are the physical and chemical properties of matter. Explain what is the difference between extensive and intensive properties with examples
A) What are the difference in properties between the silicon substrate and the oxide layer? B)...
A) What are the difference in properties between the silicon substrate and the oxide layer? B) Design a process that produces the oxide layer on a silicon wafer. C) Design a process that forms the oxide layer only in certain desired areas.
Identify one element that shares Knight's move properties with Mg? what properties would be similar? What...
Identify one element that shares Knight's move properties with Mg? what properties would be similar? What must be true of each element?
What are two basis properties which indicates that this metal has magnetic properties. What is the...
What are two basis properties which indicates that this metal has magnetic properties. What is the role of paired and unpaired electronic spin in characterizing the properties of the metal/ material
Difference between composition and properties of concrete and asphalt mixes
Difference between composition and properties of concrete and asphalt mixes
3. What is the difference between oligopoly and monopoly?
3. What is the difference between oligopoly and monopoly?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT