Using hide()/show() with elements I hid 'manually'?
I'd like to prepare a page using jsp, hiding an element in the jsp, then showing it using jquery later on, something like:
// index.jsp:
<%
<div id='hideme' style='hidden: true' >hello</div>
%>
<!-- At runtime: -->
$('#hideme').show();
What's the right way to hide the div in the jsp code such that开发者_开发技巧 the jquery hide()/show() methods will work correctly with it later on?
Thanks
The show()
and hide()
methods operate on the css display
property.
So what you would want is
// index.jsp:
<%
<div id='hideme' style='display:none' >hello</div>
%>
Reference
- http://api.jquery.com/hide/
Simply use style='display: none'
to hide them when rendering and jQuery show/hide will work with your server-side generated hidden elements.
for your element to work properly use proper css properties
helloto show
$('#hideme').show('slow');
to hide
$('#hideme').hide('slow');
you can call them in one function or two separate functions respectively
精彩评论