We help IT Professionals succeed at work.

jquery click event not working in IE 7 or 8

dolythgoe
dolythgoe asked
on
I've spent ages reading and trying different things to work but I can't get the onclick event to work in IE like it does in every other browser!

The link code:

<a href="#" id="signupopen">QUICK SIGNUP</a>

Open in new window


js is called before in the <head> (tried putting it at bottom too but didn't work

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquerywindow.js"></script>

Open in new window


jquery code in jquerywindow.js :

		$('#signupopen').click(function() {
			$signup.load('signup.php').ready(
			$signup.dialog('open'));
			// prevent the default action, e.g., following a link
			return false;
		});

Open in new window


Also tried:

		$('#signupopen').live("click", function() {
			$signup.load('signup.php').ready(
			$signup.dialog('open'));
			// prevent the default action, e.g., following a link
			return false;
		});

Open in new window


To no avail :(

Would love some help through this IE deugging nightmare!
Comment
Watch Question

its working for me.

$('#signupopen').click(function() {
alert("aa")
			$signup.load('signup.php').ready(
			$signup.dialog('open'));
			// prevent the default action, e.g., following a link
			return false;
		}); 
});
 	/*	$('#signupopen').live("click", function() {
			$signup.load('signup.php').ready(
			$signup.dialog('open'));
			// prevent the default action, e.g., following a link
			return false;
		}); */
  </script>
 </HEAD>

 <BODY>



 		

  <a href="#" id="signupopen">QUICK SIGNUP</a> 

Open in new window

put these js files at the top of document.ready.use   $(document).ready(function() {
});
  $(document).ready(function() {

$('#signupopen').click(function() {
alert("aa")
			$signup.load('signup.php').ready(
			$signup.dialog('open'));
			// prevent the default action, e.g., following a link
			return false;
		}); 
});

Open in new window

Author

Commented:
Sorry forgot to say they already are in this function and still no luck :(
atleast are you getting alert?

$(document).ready(function() {

  $('#signupopen').click(function() {
		alert("aa")
			$signup.load('signup.php').ready(
			$signup.dialog('open'));
			// prevent the default action, e.g., following a link
			return false;
		}); 
});
  </script>
 </HEAD>

 <BODY>

  <a href="#" id="signupopen">QUICK SIGNUP</a>  

Open in new window

instead of hyperlink if u use button then whats hapening.

  <input type='button' value='click' id="signupopen">QUICK SIGNUP</a>  

Author

Commented:
Yes it's ok when I paste it into the top like you show..

But not as a seperate script which is full of other similar functions etc..

Cheers
then in that case some where in the js file ,error is obstructing calling this function.try to remove the other functions one by one and check this function is caling or not.

Author

Commented:
Cool...

Well, it was a rogue comma that IE didn't like.

I had this before the function:

		var $resend = $('#resend')
			.dialog({
				autoOpen: false,
				title: 'Activation Required',
				draggable: false,
				modal: true,
				resizable: false,
				width: 420,
				height: 360,
				position: ['center',100],

				
			});

Open in new window


I did read about this and thought I'd removed all trailing commas but one remained after position: ['center',100]. I removed this and all works fine :D

Thanks for your help sorting this out!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.