Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 6 years ago

#6392 closed enhancement (wontfix)

$('DIV#myId').attr('for') - im can't read value of "for" attribute, if i'm rename this attribute, all is work

Reported by: leadaxe Owned by:
Priority: low Milestone: 1.5
Component: manipulation Version: 1.4.2
Keywords: attr Cc: paulirish, kswedberg
Blocked by: Blocking:


bug demo example: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <div for="test" id="myId"></div> <div fortest="test" id="myId2"></div> <script>$(function(){

alert('$("#myId").attr("for") is "'+$("#myId").attr("for")+'"'); alert('$("#myId2").attr("fortest") is "'+$("#myId2").attr("fortest")+'"');


Attachments (1)

test-6392.html (476 bytes) - added by dmethvin 8 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by miketaylr

divs don't have for attributes--only labels: http://www.w3.org/TR/REC-html40/interact/forms.html#adef-for

comment:2 Changed 8 years ago by leadaxe

ok, but it is work for any different undeclared attributes.

Changed 8 years ago by dmethvin

Attachment: test-6392.html added

comment:3 Changed 8 years ago by dmethvin

This is because the "for" property when used in HTML is actually "htmlFor", for example in the label element. That would be true of any of the special cases in jQuery.props I suspect. XML documents don't get this special treatment so "for" would be "for" there. I'm not sure whether this is worth fixing, or just documenting.

comment:4 Changed 8 years ago by SlexAxton

Cc: paulirish kswedberg added
Priority: low
Resolution: wontfix
Status: newclosed
Type: bugenhancement

+1 for documenting.

Closing the ticket as it is not a bug, but cc'ing people who <3 documentation.

Note: See TracTickets for help on using tickets.