开发者

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

hello

to show

$('#hideme').show('slow');

to hide

$('#hideme').hide('slow');

you can call them in one function or two separate functions respectively

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜