Exam4Training

Which code change should be made for the console to log only Row log when ‘Click me! ’ is clicked?

Refer to the code below:

<html lang=”en”>

<table onclick=”console.log(Table log’);”>

<tr id=”row1”>

<td>Click me!</td>

</tr>

<table>

<script>

function printMessage(event) {

console.log(‘Row log’);

}

Let elem = document.getElementById(‘row1’);

elem.addEventListener(‘click’, printMessage, false);

</script>

</html>

Which code change should be made for the console to log only Row log when ‘Click me! ’ is clicked?
A . Add.event.stopPropagation(); to window.onLoad event handler.
B . Add event.stopPropagation(); to printMessage function.
C . Add event.removeEventListener(); to window.onLoad event handler.
D . Add event.removeEventListener(); toprintMessage function.

Answer: B

Exit mobile version