i have a div dynamically created on page load using php. the id is ‘A’.
When click on ‘A’ , another div is shown. Name is ‘B’. this div is a child div of ‘A’.
now ‘B’ div has onclick hide(‘B’).
But when i click it does not hide itself. strage. but if i put another element name for example ‘A’, Then it works.
why ‘B’ is not hiding itself while it hideS any other element on that page including it’s parent ‘A’?
function hide(name){
document.getElementById(name).style.display='none';
}
function show(name){
document.getElementById(name).style.display='block';
}
<div class="marker" id="marker" onclick="hide('marker')">Click me to hide</div>
<script>
function hide(name){
document.getElementById(name).style.display='none';
}
</script>