Ticket #4143 (closed bug: invalid)
http://www.gcforum.org/forumdisplay.php?fid=2410 can't not use jQuery selector to find elements??
| Reported by: | Jumann | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3.2 |
| Component: | unfiled | Version: | 1.3.1 |
| Keywords: | selector | Cc: | |
| Blocking: | Blocked by: |
Description
as title. I can't use jQuery selector to find html dom element. example: var body = jQuery('body');==> body.length will be 0; but get(0) will returned the element. var wrap = jQuery('div#wrap', body); ==> wrap.length will be 0; but get(0) will returned undefined. Is this a bug in jQuery 1.3.1???
Change History
comment:1 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to worksforme
comment:2 Changed 4 years ago by Jumann
- Status changed from closed to reopened
- Resolution worksforme deleted
javascript:(function(){window.t=document.createElement('script');window.t.src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js';window.document.body.appendChild(window.t);setTimeout(function(){alert(jQuery('body').length);},2000)})();
You can copy the sentence above here. Then link to http://www.gcforum.org/forumdisplay.php?fid=2410 and paste it to address bar. It both returned 0 in FF3 and IE7. Thanks for your reply.
comment:3 follow-up: ↓ 5 Changed 4 years ago by dmethvin
It sounds like some other code on that page is interfering with jQuery. I couldn't see it in a quick look at common.js where I figured it would be. So, if you can create a simple test case that demonstrates the problem, attach it. If you need help debugging the code, it would be best to post on a forum because we haven't yet established this is a bug in jQuery. A simple test case would help to determine that.
comment:4 Changed 4 years ago by Jumann
I found commom.js overrides Array.prototype.push function.
Array.prototype.push = function(value) {
this[this.length] = value;
return this.length;
}
It seems that affects result of "ret.push( array[i] )". (at 2026 line of jQuery1.3.1.js) It caused jQuery('body');==> body.length will be 0; Does that problem resemble #2721?
comment:5 in reply to: ↑ 3 Changed 4 years ago by Jumann
I found commom.js overrides Array.prototype.push function.
Array.prototype.push = function(value) {
this[this.length] = value;
return this.length;
}
It seems that affects result of "ret.push( array[i] )". (at 2026 line of jQuery1.3.1.js) It caused jQuery('body');==> body.length will be 0; Does that problem resemble #2721?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

That would be pretty obvious if it didn't work. I tried alert(jQuery('body').length) with 1.3.1 and 1.2.6 in FF3 and IE7 and they both returned 1 as they should. If you can create a simple test case, attach it.