0

Ok this is my problem that no one can seem to answer. I have two javascripts in use. Once is for the popup I have and tells it to stay closed for 24hrs when closed. The other is to put a link some where on the page to display this popup until refreshed and kept hidden till the cookie expires. Now the div popup is set to display:none. The cookie tells it to be shown until the close button is pressed. No matter what I seem to rework in my javascript to tempoarly show the popup from a link, it will not show. Some how the cookie javascript is going to have to be modified and thus having to remove css:display:none on the popup div. I have no idea what to do.

This is the current code:


<script type="text/javascript"> 
$("#linkshow").click(function {
$("#window").show()
});        
</script>

<a href="#" id="linkshow">Submit a comment</a>
<div id="window">
...
<div>
<script type="text/javascript">
...cookie popup hide for 24hr on close
</script>

Note: I have already tried:

$(document).ready(function() {
   $("#linkshow").click(function(e) {
      e.preventDefault();
      $("#window").show();
   });
}); 

and...

$(document).ready(function() {
     $("#window").hide();

   $("#linkshow").live('click', function(e) {
      e.preventDefault();
      $("#window").show();
   });
}); ​

and...

$(function() {
        $("#linkshow").click(function() {
            $("#window").show()
        });        
    });

and...

<div id="window" style="display:none;">

to

<div id="window">

Then the other 24hr cookie javascript doesn't keep the popup hidden. I am assuming I need to take out the id="window" style="display:none; and some how advanced the javascript cookie at the bottom the code so it will hide when asked to be hidden for 24hr and show when needed to be shown on the current page until refresh but I am at blank on what to do.

2
  • Please try to explain better. I don't understand what you are trying to say. You have some spelling-errors too. Commented May 21, 2012 at 11:38
  • I already have another javascript code implemented that works to close a popup and sets a cookie to remember the hidden state for 24hrs. Now I am trying to make a javascript link to force display this comment box. Commented May 21, 2012 at 11:46

2 Answers 2

2

Your syntax is wrong, Try

$(document).ready(function() {
   $("#linkshow").click(function(e) {
      e.preventDefault();
      $("#window").show();
   });
}); 

Works for me: See jsFiddle

Sign up to request clarification or add additional context in comments.

Comments

0

You need to wrap your code in a DOM ready handler, and you also missed the brackets following the function declaration. Try this:

<script type="text/javascript"> 
    $(function() {
        $("#linkshow").click(function() {
            $("#window").show()
        });        
    });
</script>

1 Comment

'What now' is you telling us in what way it's not working. Are there any errors in your JavaScript console? Have you tried to debug, and find out where the code 'breaks'?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.