Solved

Hide/display a div element in JQuery

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

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
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…

840 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