Skip to main content

Bug Tracker

Side navigation

#7738 closed bug (duplicate)

Opened December 09, 2010 05:55PM UTC

Closed December 09, 2010 05:56PM UTC

Last modified December 09, 2010 05:56PM UTC

Selectors broken if attribute name="id"

Reported by: paul@thebishopway.com 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.

Attachments (0)
Change History (2)

Changed December 09, 2010 05:56PM UTC by rwaldron comment:1

resolution: → duplicate
status: newclosed

Changed December 09, 2010 05:56PM UTC by rwaldron comment:2

Duplicate of #7212.