Bug Tracker

Opened 7 years ago

Closed 6 years ago

Last modified 5 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 7 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 7 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 7 years ago by leadaxe

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

Changed 7 years ago by dmethvin

comment:3 Changed 7 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 6 years ago by SlexAxton

  • Cc paulirish kswedberg added
  • Milestone changed from 1.4.2 to 1.5
  • Priority set to low
  • Resolution set to wontfix
  • Status changed from new to closed
  • Type changed from bug to enhancement

+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.