Solved

Hide/display a div element in JQuery

Posted on 2013-06-16
3
380 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery add something to a div 4 43
Master Content Pages, WebForms, and Session Variables 1 45
add a 3rd selection to sum 7 29
jqury 17 30
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

773 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