Skip to main content

Bug Tracker

Side navigation

#1964 closed bug (wontfix)

Opened November 23, 2007 05:39PM UTC

Closed June 12, 2008 10:42PM UTC

onclick ie7

Reported by: phoenixenator Owned by:
Priority: undecided Milestone: 1.2.2
Component: event Version: 1.2.1
Keywords: onclick ie7 Cc: Phoenixenator
Blocked by: Blocking:
Description

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>jQuery bug</title>

<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>

<script type="text/javascript">

$(document).ready(function() {

$('#txt').attr('onclick', 'alert("hello");');

});

</script>

</head>

<body>

<input id='txt' type='text' value='vide'/>

</body>

</html>

With this code they are no event with ie7.

Attachments (1)
  • bug.zip (14.1 KB) - added by phoenixenator November 23, 2007 05:40PM UTC.

    source code of bug

Change History (4)

Changed November 26, 2007 09:54AM UTC by gudoy comment:1

I suppose it's also related to the fact that under IE 6 and IE 7, $(element).attr('onclick') returns a Function instead of a String.

Changed November 27, 2007 06:31PM UTC by davidserduke comment:2

milestone: 1.2.11.2.2
resolution: → wontfix
status: newclosed

jQuery has its own event handling system so doesn't support the onclick (and other) attributes. Try:

$('#txt').click(function () { alert("hello"); });

Closing this bug on that basis.

Changed June 12, 2008 09:10PM UTC by sircastor comment:3

resolution: wontfix
status: closedreopened

$.attr() ought to add whatever attribute requested, regardless of purpose.

Changed June 12, 2008 10:42PM UTC by flesler comment:4

resolution: → wontfix
status: reopenedclosed

IE (6/7) doesn't support this action (setting string handlers). That's why there's no need to add bytes of code to support it.

You can always do this by affecting the original dom elements and using setAttribute. It won't work on IE, but that's your decision.