Skip to main content

Bug Tracker

Side navigation

#4627 closed bug (invalid)

Opened May 05, 2009 06:21PM UTC

Closed May 06, 2009 02:27AM UTC

JQuery appendTo Bug

Reported by: lagden Owned by:
Priority: critical Milestone: 1.4
Component: core Version: 1.3.2
Keywords: append, appendTo Cc: lagden@gmail.com
Blocked by: Blocking:
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 (1)
  • appendTo.htm (1.5 KB) - added by lagden May 05, 2009 06:23PM UTC.

    sample bug file

Change History (1)

Changed May 06, 2009 02:27AM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

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.

For more information see #4575 and #3113.