Skip to main content

Bug Tracker

Side navigation

#9998 closed bug (worksforme)

Opened August 08, 2011 09:16AM UTC

Closed August 08, 2011 09:34AM UTC

.attr('onchange') returns undefined

Reported by: anonymous Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

When trying to collect onchange using 1.6.1 it returns undefined. Yet when trying to collect onchange using 1.5.1 it returns the correct funtion.

This is the c# rendered code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head><title>Not working</title>
<script type="text/javascript" src="includes/jquery-latest.pack.js"></script>
<script type="text/javascript">
$(function() {
alert( $('#ddlJobRole').attr('onchange') );
<select name="ddlJobRole" onchange="javascript:setTimeout('__doPostBack(\\'ddlJobRole\\',\\'\\')', 0)" id="ddlJobRole">
<option selected="selected" value="">Please Select...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
Attachments (0)
Change History (1)

Changed August 08, 2011 09:34AM UTC by addyosmani comment:1

component: unfiledattributes
priority: undecidedlow
resolution: → worksforme
status: newclosed

I've put together a test case on jsFiddle matching the code you've supplied and it's working fine for me across Chrome, Firefox, Opera and IE9. This is using jQuery 1.6.2 (and not 1.6.2, which is an older release). Please double check that your solution works fine with 1.6.2 or jQuery edge as it works for me.