views:

95

answers:

4

Hello.

Im using JQuery with css to show div's on a page with the Click command.

like this code here.

$("#img1_hover").click(
 function(){
    $('#img1_show').addClass('img1_show_vis');
    $('#img_shower_1').addClass('img_shower_vis');
    $('#close_btn_1').addClass('img1_show_x_vis');
 }

The code work fine under Firefox but it doesnt work under IE. Anyone have an idea why??

Thanks for your reply!

the page can be seen at http://martinesavard.com/template.php

+2  A: 

Try returning false.

$("#img1_hover").click(function(){
  $("#img1_show").addClass("img1_show_vis");
  $("#img_shower_1").addClass("img_shower_vis");
  $("#close_btn_1").addClass("img1_show_x_vis");
  return false;
});

One, thing about your code is that you have a div tag that receives the clicks and I'm starting to think that div is collapsed or not is the proper place where you expected it to be. Try adding a border to the divs that will receive the click to visualize if they are where they need to be.

In Firebug I ran this:

jQuery("#img1_hover").css("border", "3px solid #f09");

Which does show the outline of where the click needs to happen. I then set the display to none so it can be hidden.

jQuery("#img1_hover").css("display", "none");

and when you can see the click area is no longer there and clicking in the same area does nothing. Just maybe that will be the issues in IE.

fernyb
still the same )=The page can be seen at http://martinesavard.com/template.php
Zero G
i think thats it. i have juste added a link inside my img1_hover div and as i clicked the link my script worked. so im gona work arround that and see what i get Thnx
Zero G
The funny thing is that the div is where it need to be. i can see it with the border. but it is empty. When i add a link in it and click the link it is working! Weird
Zero G
i dont even need a link. all i need is something in the div like my images. When the div is emty its not working under IE. as soon as i place something in the div its working.
Zero G
+1  A: 

Try running you event attachment stuff in a '$(document).ready' instead of in a <script> outside of any function - maybe IE doesn't have the DOM quite ready yet when your code runs.

Ray
i tried that. But i have to keep the <script> tags right? otherwise the JS code show in my page. so the $(document).ready come's in right after the <script> tags?
Zero G
<script language="javascript" type="text/javascript">$(document).ready( function() { $("#img1_hover").click( function(){ alert("called"); $(\'#img1_show\').addClass(\'img1_show_vis\'); $(\'#img_shower_1\').addClass(\'img_shower_vis\'); $(\'#close_btn_1\').addClass(\'img1_show_x_vis\'); return false; }); }); </script>this is the new code with all the suggestions.
Zero G
the click function is not being called within IE8
Zero G
A: 

Try closing your parenthesis:

$("#img1_hover").click(
 function(){
    $('#img1_show').addClass('img1_show_vis');
    $('#img_shower_1').addClass('img_shower_vis');
    $('#close_btn_1').addClass('img1_show_x_vis');
 }

becomes:

$("#img1_hover").click(
 function(){
    $('#img1_show').addClass('img1_show_vis');
    $('#img_shower_1').addClass('img_shower_vis');
    $('#close_btn_1').addClass('img1_show_x_vis');
 });
cdmckay
$("#img1_hover").click(function(){ alert("called"); $(\'#img1_show\').addClass(\'img1_show_vis\'); $(\'#img_shower_1\').addClass(\'img_shower_vis\'); $(\'#close_btn_1\').addClass(\'img1_show_x_vis\'); return false; });still not working. Thx tho
Zero G
A: 

Your images are behind your outer frame. Your clicks aren't making it through. (The div with class "frame" has a z-index of 100, while your image divs have 99.)

Pointy
thers another div at z-index 101 to catch the clicks on top of the image.
Zero G
it would be worth a try to remove the page from the frame to see if pointy's theory is correct - I notice that with IE developer tools, a click on the image actually selects the frame, whereas in firebug/firefox, a click selects the image.
Ray
That other div, how's it working out?
Pointy