Opened 13 years ago
Closed 13 years ago
#5406 closed bug (invalid)
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?
Change History (2)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
Note: See
TracTickets for help on using
tickets.
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>