Bug Tracker

Modify

Ticket #7738 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

Selectors broken if attribute name="id"

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

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

comment:1 Changed 3 years ago by rwaldron

  • Status changed from new to closed
  • Resolution set to duplicate

comment:2 Changed 3 years ago by rwaldron

Duplicate of #7212.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.