Solved

Hide/display a div element in JQuery

Posted on 2013-06-16
3
378 Views
Last Modified: 2013-06-21
Looks like the 'hide' works but the 'show; isn't.

1. I have the div below, with a literal. I bind the literal-text from the database
 <div  id="bottomLetter">
   <asp:Literal runat="server"  ID="lBottomLetter"></asp:Literal>
  </div>

Open in new window


2. When the page loads, I don't want the text to be displayed. So, in the aspx page, I have
<script type="text/javascript">
    $(document).ready(function (e) {
        $('#bottomLetter').hide();
    });
</script>

Open in new window


3. Use clicks a button, I call a Javascript, and in it, I set the div to show. But the text doesnt show up.  I looked at page-source and  I see this. It's still set to display: none.
<div style="display: none;" id="bottomLetter">
$('#bottomLetter').show();

Open in new window


4. I put alert and i do see the text of that literal. So, the text is there
     
var contents = $('#bottomLetter')[0];
     alert(contents.innerHTML);

Open in new window


What am I missing?
0
Comment
Question by:Camillia
  • 2
3 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39251685
Where's the button click code?
0
 
LVL 7

Accepted Solution

by:
Camillia earned 0 total points
ID: 39251718
I just played around with it and it works. I think I was missing the second line of code.

$('#bottomLetter').show();
var bottomPart = $('#bottomLetter')[0];
0
 
LVL 7

Author Closing Comment

by:Camillia
ID: 39265333
found my answer
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now