How we can hide a block of html code on a button click using jquery?



How we can hide a block of html code on a button click using jquery?..

Answer / Anup Kumar Pandey

To hide a block of HTML code on a button click using jQuery, you can use the `hide()` method. Here is an example:

```html
<button id='myButton'>Hide Element</button>
<div id='myDiv'>This is the div to be hidden</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('#myButton').click(function() {
$('#myDiv').hide();
});
});
</script>

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More jQuery Interview Questions

How to call a method inside code-behind using jquery?

1 Answers  


How to use migrate jquery plugin if possible? : jquery mobile

1 Answers  


What are selectors in jquery? Explain

1 Answers  


What is the goal of cdn and what are the advantages of using cdn?

1 Answers  


Which selector has better performance id or class and why?

1 Answers  


What is the use jQuery.data method?

1 Answers  


Is jQuery is a replacement of JavaScript?

1 Answers  


Explain the difference between jquery's ready and holdready?

1 Answers  


How can we apply css in div using jquery?

1 Answers  


Difference between prop() and attr()? : jQuery Mobile

1 Answers  


How to disable jQuery animation?

2 Answers  


Can we have multiple document.ready() function on the same page?

1 Answers  


Categories