0

i have this setup:

<script type="text/javascript">
$(document).ready(function() {
   $("#click_me_link").click(function () {
      $("#link_more").show("slow");
   });
});
</script>

<div id="click_me_link"><img src="/images/banner_bottom.png"></div>
<div id="link_more" style="width: 530px; height: 66px; display: none;">
   test
</div>

if i click on the click_me_link it wont display the hidden div. if i run $("#link_more").show("slow"); in the console it works

any idea? thanks semicolon fixed, still doesn't work

3
  • Check to see if there is an error in your javascript. Commented Jun 22, 2011 at 23:35
  • anything on the console? Commented Jun 22, 2011 at 23:36
  • You missed a semicolon between the height and display properties in the link_more's style. Does that fix the issue? Commented Jun 22, 2011 at 23:39

3 Answers 3

4

Yeah the issue is your css in link_more. You are missing a semicolon. It needs to be this:

width: 530px; height: 66px; display: none;

Anyway, you probably want to make click_me_link an anchor instead of a div and use e.preventDefault() inside your click event.

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

3 Comments

Actually, that wouldn't prevent the hidden div from showing. It would prevent it from being hidden in the first place.
Yeah, that was the only issue I found when I moved it to jsfiddle. I am guessing the overall cause must be a browser issue.
+1 For saying you should wrap the image in an anchor tag. This will make the web page more accessibility friendly for screen readers and any browser with JavaScript disabled.
1

It's working here http://jsfiddle.net/imoda/eXPW5/

You're missing a ; after the height property

<div id="link_more" style="width: 530px; height: 66px display: none;">

Not sure if that's causing your problem as I can't seem to replicate it, but it's no doubt something to fix.

2 Comments

There's no way that would be the answer. See my comment on John Kalberer's answer. Missing a semicolon would prevent the DIV from being hidden. It would not prevent it from being shown upon a click event. It would cause the exact opposite of the problem stated!
I agree. My guess is that there are other things at play that are having some sort of effect. Going off what OP has provided, this doesn't fix what he's talking about.
1

You were missing a semi-colon after "66px". Other than that, your example is working for me.

Here is a working jsfiddle: http://jsfiddle.net/Mm9AQ/

Comments

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.