Q
Which JavaScript property is used to change the source (URL) of an image element?

Answer & Solution

Answer: Option A
Solution:
The src property in JavaScript is used to change the source (URL) of an image element. By assigning a new URL to the src property of an image element, you can dynamically change the image displayed on the webpage.
Related Questions on Average

How can you dynamically change the background color of an HTML element based on user actions using JavaScript?

A). Use event listeners like addEventListener to detect user actions and update the element's background color

B). Use inline JavaScript in the HTML element's onclick attribute to change the background color

C). Use the onHover event directly in the HTML element's tag to change the background color

D). Use the element.background = 'color'; property in JavaScript to directly modify the element's background color

What does the appendChild() method do in JavaScript?

A). Appends a new child node to an existing element in the DOM

B). Removes a child node from an existing element in the DOM

C). Replaces an existing child node with a new node in the DOM

D). Creates a new parent node for an existing child node in the DOM

Which JavaScript event is triggered when a user clicks on an HTML element?

A). click

B). hover

C). submit

D). change

Which JavaScript method is commonly used to create a new HTML element dynamically?

A). document.createElement()

B). document.appendElement()

C). document.makeElement()

D). document.createNode()

Which JavaScript method is used to replace one HTML element with another in the DOM?

A). replaceChild()

B). replaceElement()

C). replaceNode()

D). element.replaceWith()

What is the purpose of using the innerHTML property in JavaScript?

A). To set or retrieve the HTML content of an element, including its descendants

B). To set or retrieve the text content of an element, including its descendants

C). To set or retrieve the value of an input element

D). To set or retrieve the URL of an anchor element

How can you hide an HTML element from the user interface using JavaScript?

A). element.style.display = 'none';

B). element.style.visibility = 'hidden';

C). element.visible = false;

D). element.style.opacity = 0;

How can you dynamically change the CSS style of an HTML element using JavaScript?

A). Use the style property of the element to modify CSS styles

B). Use the setStyle() method to apply CSS styles to the element

C). Use inline CSS within the HTML element's tag to specify styles

D). Use external CSS files and link them to the HTML document

How can you dynamically change the text content of an HTML element based on user input using JavaScript?

A). Use event listeners like addEventListener to detect input changes and update the element's text content

B). Use inline JavaScript in the HTML element's onclick attribute to update the text content

C). Use the onChange event directly in the HTML element's tag to update the text content

D). Use the inputValue property in JavaScript to directly modify the element's text content

How can you change the background color of an HTML element using JavaScript?

A). element.style.backgroundColor = 'red';

B). element.background = 'red';

C). element.bgColor = 'red';

D). element.color = 'red';