Bug Tracker

Ticket #6392 (closed enhancement: wontfix)

Opened 6 years ago

Last modified 4 years ago

$('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
Blocking: Blocked by:


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")+'"');



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

Change History

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

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

Changed 5 years ago by dmethvin

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

  • Status changed from new to closed
  • Cc paulirish, kswedberg added
  • Resolution set to wontfix
  • Priority set to low
  • Milestone changed from 1.4.2 to 1.5
  • 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.