Ticket #4627 (closed bug: invalid)
JQuery appendTo Bug
| Reported by: | lagden | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.4 |
| Component: | core | Version: | 1.3.2 |
| Keywords: | append, appendTo | Cc: | lagden@… |
| Blocking: | Blocked by: |
Description
<script type="text/javascript"> var controllerID='11'; var controllerEID='1'; var controllerPARENTID='0';
$(document).ready(function(){
Bug $('<input type="hidden" name="id" value="'+controllerID+'" />').appendTo('#frm');
Fine $('<input type="hidden" name="uid" value="'+controllerID+'" />').appendTo('#frm');
$('<input type="hidden" name="eid" value="'+controllerEID+'" />').appendTo('#frm'); $('<input type="hidden" name="parentId" value="'+controllerPARENTID+'" />').appendTo('#frm');
$('#bt').click(function(){postar();return false;});
});
function postar(){
var f=$('#frm');
Bug returns [object HTMLInputElement]<input type="hidden" value="11" name="id"> Expected frm alert(f.get(0).id); }
</script>
</head> <body>
<form action="post.php" id="frm" method="post" onsubmit="return false;">
<label for="nome">Nome completo:</label> <input type="text" id="nome" name="nome" /><br/> <button id="bt">OK</button>
</form>
</body> </html>
Attachments
Change History
Changed 4 years ago by lagden
-
attachment
appendTo.htm
added
comment:1 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
The key is this line in your example:
alert(f.get(0).id);
The bug you are reporting is actually outside jQuery, since f.get(0) gets the raw DOM element and you are selecting the id property.
There are already open bugs requesting that jQuery work around this browser bug where possible, but this particular case could not be worked around at all by jQuery since the bug at the point of use is raw DOM and not jQuery.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

sample bug file