[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Karl Swedberg
On May 18, 2007, at 2:32 PM, Michael Geary wrote: Even if the jQuery code previously posted does the trick, every web developer should have this extension, so go get it now: http://jennifermadden.com/scripts/ViewRenderedSource.html Now you can locate the duplicate ID by selecting View Source

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Michael Geary
> From: [EMAIL PROTECTED] > > How can I use JQuery to discover if a particular ID occurs > twice in my page? I can't use "View Source' because the DOM > is changing as the user interacts with the page. Reading between the lines here, it sounds like you don't have the View Source Chart plugin

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Karl Swedberg
Who needs consensus? All we need is a test :-) : http://test.learningjquery.com/multipleid.html --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On May 18, 2007, at 2:01 PM, [EMAIL PROTECTED] wrote: Just wanted to get consensus, will this work if ($('[

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread [EMAIL PROTECTED]
Just wanted to get consensus, will this work > if ($('[EMAIL PROTECTED]').length == 2) { >// do something ? > > } > ? Thanks, - Dave On May 18, 9:07 am, Karl Swedberg <[EMAIL PROTECTED]> wrote: > You could try this: > > if ($('[EMAIL PROTECTED]').length == 2) { >// do something ? > >

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Karl Swedberg
On May 18, 2007, at 9:57 AM, Michael Price wrote: Try: if ($("#your_id_here").length > 1) { // CODE TO EXECUTE } I don't think that will work, because jQuery will only ever match zero or one element by id using the "#" id selector. --Karl _ Karl Swedberg www.englishr

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Michael Price
No, that won't work. And ID-selector returns always zero or one elements. But you can use this: $("[EMAIL PROTECTED]").size() > 1 Fair enough, I learn something new every day :) I just assumed (bad idea) it would work, I was coding off the top of my head, so to speak. Regards, Michael Pri

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Jörn Zaefferer
Michael Price wrote: [EMAIL PROTECTED] wrote: Hi, How can I use JQuery to discover if a particular ID occurs twice in my page? I can't use "View Source' because the DOM is changing as the user interacts with the page. Try: if ($("#your_id_here").length > 1) { // CODE TO EXECUTE } No,

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Karl Swedberg
You could try this: if ($('[EMAIL PROTECTED]').length == 2) { // do something ? } That selector will probably be a little slow, though, depending on the complexity of the DOM, because it has to crawl through every single element. if you can narrow it down to within a certain div, that wo

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Klaus Hartl
Michael Price wrote: [EMAIL PROTECTED] wrote: Hi, How can I use JQuery to discover if a particular ID occurs twice in my page? I can't use "View Source' because the DOM is changing as the user interacts with the page. Try: if ($("#your_id_here").length > 1) { // CODE TO EXECUTE } Thi

[jQuery] Re: using jquery to see if an ID occurs twice

2007-05-18 Thread Michael Price
[EMAIL PROTECTED] wrote: Hi, How can I use JQuery to discover if a particular ID occurs twice in my page? I can't use "View Source' because the DOM is changing as the user interacts with the page. Try: if ($("#your_id_here").length > 1) { // CODE TO EXECUTE } This should fire the code