I want to show() '<div id='test'>write text here</div' on click and not on page load.
$(document).ready(function() { $('#click_test').stop(function(event) { event.preventDefault(); $('#test').slideup(); }); $('#click_test').click(function(event) { event.preventDefault(); $('#test').toggle(); }); });
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script> <a href='#' id='click_test'>Click Here</a> <div id='test'>write text here</div>
add
$('#test').hide();in your javascript:Alternatively in your html:
gives the same result