Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7738 closed bug (duplicate)

Selectors broken if attribute name="id"

Reported by: paul@… Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:

Description

Between jQuery 1.4.2 and 1.4.3 I noticed a difference in behaviour that I can't find documented. This may be a bug.

Selecting elements within another element that has an input the the attribute name="id" seeems to confuse the selector. It worked in jQuery 1.4.2 but fails in 1.4.3. Different browsers fail differently.

In the followign code, if jQuery 1.4.2 is used, both of these selectors will update the value of the input fields. If jQuery 1.4.3 is used, different selectors fail depending on which browser is used. FF3.6 will fail the 1st, Chrome fails the 2nd.

This only seems happens on 1.4.3 if the hidden input's "name" attribute is "id".

<html><head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<form id="myForm" onSubmit="return updateform($(this))">
	<input type="hidden" name="id" val="test">
	<input type="text" name="username1">
	<input type="text" name="username2">
	<input type="submit">
</form>
<script type="text/javascript">
function updateform(formRef) {
	$('input[name="username1"]', formRef).val('Using Context');
	$('#myForm input[name="username2"]').val('Direct Select');
	return false;
}
</script>
</body></html>

The above code was tested in firefox 3.6.

Change History (2)

comment:1 Changed 8 years ago by Rick Waldron

Resolution: duplicate
Status: newclosed

comment:2 Changed 8 years ago by Rick Waldron

Duplicate of #7212.

Note: See TracTickets for help on using tickets.