Skip to main content

Bug Tracker

Side navigation

#5406 closed bug (invalid)

Opened October 24, 2009 12:41PM UTC

Closed October 25, 2009 01:24PM UTC

selector + variable name cannot be the same in IE

Reported by: IGonza Owned by: john
Priority: major Milestone: 1.3.2
Component: selector Version: 1.3.2
Keywords: selector Cc:
Blocked by: Blocking:
Description

function testbug() {

test_field = $("#test_field");

}

<input type="text" value="1" id="test_field"><a href="javascript:void(0)" onClick="javascript:testbug();">Click me</a>

That function returns an error in IE 7. But works in FF, Safari, Chrome.

Row : test_field = $("#test_field"); returns an error;

Row : var test_field = $("#test_field"); works fine.

Is it a bug?

Attachments (0)
Change History (2)

Changed October 24, 2009 03:58PM UTC by pbcomm comment:1

try this:

function testbug() {

var test_field = $("#test_field");

}

<input type="text" value="1" id="test_field"><a href="javascript:void(0)" onclick="testbug()">Click me</a>

Changed October 25, 2009 01:24PM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

IE puts names and ids into the global namespace. jQuery can't really work around that. So, do not give any elements a name or id that is the same as a variable in your Javascript code.

http://www.phpied.com/browser-implied-globals/

http://yura.thinkweb2.com/domlint/