Ticket #1964 (closed bug: wontfix)
onclick ie7
| Reported by: | phoenixenator | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.2.2 |
| Component: | event | Version: | 1.2.1 |
| Keywords: | onclick ie7 | Cc: | Phoenixenator |
| Blocking: | Blocked by: |
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
Change History
comment:1 Changed 5 years ago by gudoy
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.
comment:2 Changed 5 years ago by davidserduke
- Status changed from new to closed
- Resolution set to wontfix
- Milestone changed from 1.2.1 to 1.2.2
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.
comment:3 Changed 5 years ago by sircastor
- Status changed from closed to reopened
- Resolution wontfix deleted
$.attr() ought to add whatever attribute requested, regardless of purpose.
comment:4 Changed 5 years ago by flesler
- Status changed from reopened to closed
- Resolution set to wontfix
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


source code of bug