Please take a look on this code:
<!DOCTYPE html>
<html lang="es">
<head runat="server">
<title>Main - Annex7</title>
<meta charset="utf-8" />
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(load);
function load() {
var objectX= $("#objectX")
objectX.click(alert('auch'));
}
</script>
Should not the 'click' event get fired when I do click on objectX??? B开发者_StackOverflow社区ut this alert is fired when I load the document...
I´m a little confused, please any help would be very well received.
Thanks in advance...
change the click event to:
objectX.click(function(){
alert('auch');
});
you need to pass a function into the event,
if you just pass an action you will get errors
You need to wrap it in a function, such as an anonymous one...
objectX.click(function() { alert('auch'); });
精彩评论