Solved

Hide/display a div element in JQuery

Posted on 2013-06-16
3
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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)

707 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