Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Hide/display a div element in JQuery

Posted on 2013-06-16
3
Medium Priority
?
389 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…
Suggested Courses

810 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