I am using the below code,
HTML code,
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<div id="one" class="two">HI WELCOME TO RESOURCESUITES.COM</div>
<button>Click me</button>
Jquery code,
$(document).ready(function(){
$("button").click(function(){
$("div#one .two").hide();
});
});
- the above code is not working.the div is not hiding.
By separating
#oneand.twoby a space, you are addressing a div with the class “two” that is a child of#one.Remove the space:
however,
would do already: IDs have to be unique anyway. There is no need to add the
.twoto the selector.