[jQuery] Re: each, index to addClass

2009-12-01 Thread yskel
Thanks - that did it. I knew I was making this a lot more difficult than it needed to be. I'd actually tried something syntactically similar to what you suggested before, but it didn't work: $(".CustomClass").each(function(i){ $(this).addClass(i); }); As you pointed out, however, this w

[jQuery] Re: each, index to addClass

2009-12-01 Thread MorningZ
"but it definitely is not doing what I expect" Start by understanding that the selector value is typically a *string* value Also, the "each" function passes an index along to the event, so with those both said: $(".CustomClass").each(function(idx){ $(this).addClass("index_" + idx); });

[jQuery] Re: each function not iterating

2009-10-21 Thread Richard D. Worth
Do you have two different forms on your page, or is it one form with an id of 'testform' and a class of 'uplform'? Your code says you want to look at the inputs in the #testform, but your email says you want to look at the inputs belonging to form.uplform. If they're the same form, you can do $(th

[jQuery] Re: each function not iterating

2009-10-21 Thread Charlie
live() doesn't support submit() http://docs.jquery.com/Events/live your each should work assuming there is an attribute "validate" in your markup instead of live look at livequery plugin j...@creatusadvertising.com wrote: Hi! I have this code: $("form.uplform").live('submit', functi

[jQuery] Re: each function not iterating

2009-10-21 Thread waseem sabjee
looks at this example var itemlist = $(".list"); itemlist.each(function(i) { // in this line notice i declared a variable i within the brackets you forget to do this. itemlist.eq(i).remove(); // .eq(i). is the magic here. }); On Wed, Oct 21, 2009 at 8:41 AM, jan wrote: > > Hi! > > Sorry to fl

[jQuery] Re: Each function gives errors in IE6

2009-09-25 Thread KeeganWatkins
hey Shane, Nick's comments above simply reinforce the need for explicit variable declaration. ignoring the "var" keyword, even when picking names that don't collide with properties of the window object, is a dangerous practice. it leads to hard-to-spot bugs, scope issues, and a whole mess of othe

[jQuery] Re: Each function gives errors in IE6

2009-09-24 Thread Nick Fitzsimons
2009/9/24 Shane Riley : > > Weird double post. Found the issue. For some reason declaring the > variable worked. So I changed it to: > var  top = (parseInt($(this).height()) / 2) - 6; > That's because "top" is already defined as a synonym for the top-level window object, and IE gets upset if you

[jQuery] Re: Each function gives errors in IE6

2009-09-24 Thread Shane Riley
Weird double post. Found the issue. For some reason declaring the variable worked. So I changed it to: var top = (parseInt($(this).height()) / 2) - 6; On Sep 24, 7:31 am, Shane Riley wrote: > I've got a simple each function that finds every subnav and assigns it > a vertical position equal to h

[jQuery] Re: each() needs documentation

2009-09-15 Thread Jānis
Yes, I really looked for it - in traversing, manipulation, and also core. But probably somehow skipped over where it was. Thank you for the link!

[jQuery] Re: each() needs documentation

2009-09-14 Thread Jonathan
Did you really look for it? It's like the 2nd or 3rd link under Core. http://docs.jquery.com/Core/each#callback On Sep 14, 6:53 am, Jānis wrote: > Hello! > > I could not find each() in jQuery's documentation. Could it be > included there, please, as I was browsing all the features to find out >

[jQuery] Re: each() causing me jip :[

2009-09-06 Thread ldexterldesign
This may help shed some more light on things: Any tips on not getting this outputting a 'continue reading' link for EVERY , but the whole bunch of 's in the post? http://pastebin.com/m6a6da785 Example here: http://test.ldexterldesign.co.uk/?page_id=9 (disable CSS and you'll see what I mean: htt

[jQuery] Re: each() causing me jip :[

2009-09-06 Thread ldexterldesign
line: 11* On Sep 7, 2:25 am, ldexterldesign wrote: > Hey guys, > > If you can help me with the fix (line: 9) below that would be great. > > each() is causing the problem for me, as it's performing the code on > each and not the total 's. Can anyone suggest a solution? > > // create a 'continue

[jQuery] Re: $.each cannot iterator my array

2009-08-28 Thread Xi Shen
yes, i made a fool mistake, and mislead jquery. thanks a lot ;) On Fri, Aug 28, 2009 at 7:05 PM, Nick Fitzsimons wrote: > > 2009/8/28 davidshe...@googlemail.com : >> i have an array initialized like >> var myArr = new Array(); >> >> later I use >> >> myArray['somestring'] = new Array(); >> myAr

[jQuery] Re: $.each cannot iterator my array

2009-08-28 Thread Nick Fitzsimons
2009/8/28 davidshe...@googlemail.com : > i have an array initialized like > var myArr = new Array(); > > later I use > > myArray['somestring'] = new Array(); > myArray['somestring'].push(mydata); > > to create and new array inside of it, and populate my data by pushing. > Then I want to use the jQ

[jQuery] Re: $.each cannot iterator my array

2009-08-28 Thread Steven Yang
you are doing a very weird thing to an array I guess jQuery detects that myArray is a reall Array. Then it iterate over it by using the "length" attribute. However you didnt actually put anything into the Array "myArray" therefore, you dont get anything. On Fri, Aug 28, 2009 at 3:49 PM, davidshe

[jQuery] Re: $.each cannot iterator my array

2009-08-28 Thread Dhruva Sagar
Can you give some sample code I could test or somethign ?? Thanks & Regards, Dhruva Sagar. Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." On Fri, Aug 28, 2009 at 4:07 PM, Xi Shen wrote: >

[jQuery] Re: $.each cannot iterator my array

2009-08-28 Thread Xi Shen
but my program want to iterator the outer array first to find out how many arrays in the myArray variable. On Fri, Aug 28, 2009 at 5:33 PM, Dhruva Sagar wrote: > You have initiallized myArray['somestring'] = new Array(); > should you be doing $.each(myArray['something'], function() {...}); ? > T

[jQuery] Re: $.each cannot iterator my array

2009-08-28 Thread Dhruva Sagar
You have initiallized myArray['somestring'] = new Array();should you be doing $.each(myArray['something'], function() {...}); ? Thanks & Regards, Dhruva Sagar. Samuel Goldwyn - "I'm willing to admit that I may not always be right,

[jQuery] Re: .each() loop with custom function

2009-08-17 Thread Ricardo
A suggested rewrite (missing parts): http://snipt.org/edit/lnx On Aug 17, 12:28 pm, Ricardo wrote: > It should be $(current_galleryXML).find("image[id="+(i+1)+"]"), you > want to concatenate i+1 with the string. > > Plugins are supposed to "return this.each()" so you keep chaining > possible > >

[jQuery] Re: .each() loop with custom function

2009-08-17 Thread Ricardo
It should be $(current_galleryXML).find("image[id="+(i+1)+"]"), you want to concatenate i+1 with the string. Plugins are supposed to "return this.each()" so you keep chaining possible $.fn.createThumb = function(){ return this.each(function(){ //do somethin with every element } };

[jQuery] Re: .each() loop with custom function

2009-08-16 Thread andrew.croce
As I said, I am new to JQuery and javascript in general, so I am not really aware of the "normal" ways. I am trying to create code that is accessible and understandable to a wider group of people, and it seems a good way to do that is to use custom functions related to the job at hand. That way I

[jQuery] Re: .each() loop with custom function

2009-08-16 Thread MorningZ
"//CREATE EACH THUMBNAIL $(this).find("thumbpath").each(i).createThumb (); <<<-- I think I am using "i" incorrectly " No, that is not correct, it would be like: $(this).find("thumbpath").each(function(i) { $(this).createThumb(i); }); and need to chang

[jQuery] Re: .each - how to write in my code?

2009-04-12 Thread Ricardo
That's unnecessary, you can use the .hover method directly on the anchors without the need for .each(), the iteration happens automatically: $("ul#menu li a").hover(function(){ // animate opacity to full $(this).find('span').stop().fadeIn('slow'); }, function(){ // animate opacit

[jQuery] Re: .each - how to write in my code?

2009-04-12 Thread Ralph Whitbeck
what jay said so for example instead of $("ul#menu a") try $("a", this) where you are selecting all the a tags in the context of this which represents the individual li tag as you iterate through the each loop. On Sun, Apr 12, 2009 at 12:18 PM, jay wrote: > > inside the each you need to referen

[jQuery] Re: .each - how to write in my code?

2009-04-12 Thread jay
inside the each you need to reference "this" or "$(this)" instead of referencing all of the elements again. On Apr 12, 11:38 am, adesign wrote: > Hello, > > I am very new to jQuery and don´t know how to write my code for every > item. > > Here is my code for a list with hover functions, I would

[jQuery] Re: .each()

2009-04-01 Thread iceangel89
thanks On Apr 1, 6:00 pm, lukejackson wrote: > .attr() and .val() are defined on the jQuery class, not the DOM > element. > > Try $(obj).attr("value") or obj.value instead > > On Apr 1, 2:46 pm, iceangel89 wrote: > > > i used .each to select all elements with id that starts with laLab > > > $("

[jQuery] Re: .each()

2009-04-01 Thread lukejackson
.attr() and .val() are defined on the jQuery class, not the DOM element. Try $(obj).attr("value") or obj.value instead On Apr 1, 2:46 pm, iceangel89 wrote: > i used .each to select all elements with id that starts with laLab > > $("*[id^=laLab]").each(function (i, obj) { >    alert(obj.attr("va

[jQuery] Re: .each()

2009-03-31 Thread iceangel89
oh i fixed it. its because i called that after getJSON and getJSON has not set the values yet. :) On Apr 1, 2:46 pm, iceangel89 wrote: > i used .each to select all elements with id that starts with laLab > > $("*[id^=laLab]").each(function (i, obj) { >    alert(obj.attr("value")); > > }); > > bu

[jQuery] Re: each on a css class

2009-02-20 Thread MorningZ
I'd take a guess that "vkfade" doesn't return the original jQuery object (keeping "chaining" alive) On Feb 20, 7:55 pm, "Dan B." wrote: > Yes it does. So that means it must be an issue with vkfade... it might > use a global variable or something. > > Thanks for the trouble shooting aid. > > Dan

[jQuery] Re: each on a css class

2009-02-20 Thread Dan B.
Yes it does. So that means it must be an issue with vkfade... it might use a global variable or something. Thanks for the trouble shooting aid. Dan On Feb 20, 5:45 pm, James wrote: > It should. But since I don't know what vkfade is and what > elements .positiveMessage is assigned to, it's hard

[jQuery] Re: each on a css class

2009-02-20 Thread James
It should. But since I don't know what vkfade is and what elements .positiveMessage is assigned to, it's hard to tell what's wrong. What happens if you replace: $(this).vkfade("00dd00") with: $(this).hide(); ? do they all hide as expected? On Feb 20, 2:38 pm, "Dan B." wrote: > so i have a clas

[jQuery] Re: each async?

2009-01-20 Thread Michael Geary
I posted a simple plugin here a few weeks ago that adds $.slowEach() and $().slowEach() methods: http://groups.google.com/group/jquery-en/msg/f52a6b8e81af20a7 -Mike > From: traunic > > Catching up on my Ajaxian RSS feed I came across an article > that linked to: > http://www.nczonline.net/blo

[jQuery] Re: $.each help for radio button validation

2008-10-22 Thread chris thatcher
It would help to see a specific example, or link to an example. My immediate response would be to make sure you can select each group individually, by wrapping it with a div or something and selecting the div, not all the radio buttons at once. that way you can handle each group one at a time and

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread ajpiano
$(".is_preferred_email").each(function() { $(this).attr("checked","checked"); }); On Oct 6, 8:14 pm, Dave Methvin <[EMAIL PROTECTED]> wrote: > > Actually, I tried both of those things first - should have mentioned > > that.  It was only after I got three elements doing > > alert($j(".is_preferred

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread Dave Methvin
> Actually, I tried both of those things first - should have mentioned > that.  It was only after I got three elements doing > alert($j(".is_preferred_email")) that I switched to using the index. Looking at your markup, it seems like it should return three elements. I don't see a problem there.

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread MorningZ
As for yout ".size()" issue this code http://paste.pocoo.org/show/87223/ works totally as expected. not sure what you have different On Oct 6, 10:41 am, BB <[EMAIL PROTECTED]> wrote: > Try: >         $j(".is_preferred_email").each( >             function(i) { >                 this.chec

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread BB
Try: $j(".is_preferred_email").each( function(i) { this.checked = false; } ); or as the posts before: $j(".is_preferred_email").attr("checked", false); On 6 Okt., 16:04, sydneyos <[EMAIL PROTECTED]> wrote: > Thanks for your input.  Here is

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread sydneyos
Thanks for your input. Here is the relevant HTML (dynamically generated) On Oct 5, 7:22 pm, MorningZ <[EMAIL PROTECTED]> wrote: > There is absolutely no way you have the selector setup correctly > > what is the HTML? > > On Oct 5, 8:53 pm, sydneyos <[EMAIL PROTECTED]> wrote: > > > I ha

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread sydneyos
Dave, Actually, I tried both of those things first - should have mentioned that. It was only after I got three elements doing alert($j(".is_preferred_email")) that I switched to using the index. On Oct 5, 7:53 pm, Dave Methvin <[EMAIL PROTECTED]> wrote: > >         $j(".is_preferred_email").eac

[jQuery] Re: $().each() only iterates through first item

2008-10-06 Thread Dave Methvin
> $j(".is_preferred_email").each( > function(i) { > this[i].checked = false; > } > ); Inside the function of each(), the first arg is the index in the array. The "this" is the actual DOM element. It looks like you thought it was the original

[jQuery] Re: $().each() only iterates through first item

2008-10-05 Thread MorningZ
There is absolutely no way you have the selector setup correctly what is the HTML? On Oct 5, 8:53 pm, sydneyos <[EMAIL PROTECTED]> wrote: > I have the following expression where is_preferred_email is a class > assigned to three elements in my page: > >         $j(".is_preferred_email").each( >

[jQuery] Re: each() odd behavior

2008-09-04 Thread Michael Geary
I don't see anything obviously wrong with your code, and I can't imagine how either of the uses of "this" in the code would get the href attribute as "this". Is the code you showed called inside a ready function - either $(document).ready() or the shorter form shown below? If that's not the probl

[jQuery] Re: each() how to change the element text ?

2008-06-07 Thread Adwin Wijaya
oo now I know it ... thank you Richard :) On Jun 7, 8:28 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote: > $('a.pop').each(function() { > $(this).text('change to something'); > > }); > > since 'this' is each DOMElement, you need to wrap it in $() to be able to > call the jQuqyer .text() metho

[jQuery] Re: each() how to change the element text ?

2008-06-07 Thread Richard D. Worth
$('a.pop').each(function() { $(this).text('change to something'); }); since 'this' is each DOMElement, you need to wrap it in $() to be able to call the jQuqyer .text() method. - Richard Richard D. Worth http://rdworth.org/ On Sat, Jun 7, 2008 at 2:31 AM, Adwin Wijaya <[EMAIL PROTECTED]> wrot

[jQuery] Re: each() how to change the element text ?

2008-06-07 Thread Dave Methvin
> this.text = 'change to something '; // won't change ... :(}); Try $(this).text('change to something '); I assume that the text depends on some element-specific info? If all the elements need the *same* text, replace all that code with $('a.pop').text('change to something ');

[jQuery] Re: $.each() versus for() -- array size inconsistency between IE and FF

2008-04-30 Thread RobG
On May 1, 12:22 pm, Dave Methvin <[EMAIL PROTECTED]> wrote: > > But this code below makes IE think J.length is larger by 1, compared > > to FF. Because of that, IE throws a fatal error in its last loop, > > since J is no longer defined. > > Most likely, there is a trailing comma in the array def

[jQuery] Re: $.each() versus for() -- array size inconsistency between IE and FF

2008-04-30 Thread Karl Rudd
That was the problem Dave. He asked it in another thread and it was sorted out. Karl Rudd On Thu, May 1, 2008 at 12:22 PM, Dave Methvin <[EMAIL PROTECTED]> wrote: > > > But this code below makes IE think J.length is larger by 1, compared > > to FF. Because of that, IE throws a fatal error in i

[jQuery] Re: $.each() versus for() -- array size inconsistency between IE and FF

2008-04-30 Thread Dave Methvin
> But this code below makes IE think J.length is larger by 1, compared > to FF. Because of that, IE throws a fatal error in its last loop, > since J is no longer defined. Most likely, there is a trailing comma in the array definition, like this: var x = [1,2,3,] IE treats that as a 4-element ar

[jQuery] Re: each() without the last element?

2008-02-13 Thread andrea varnier
On 13 Feb, 10:37, howa <[EMAIL PROTECTED]> wrote: > Hello, I want to loop thru each elements with the each() function, > except I want to skip the last element, are there simple method? hi, I would exclude the last item directly within the selector $('#elements').not(':last').each(function(){

[jQuery] Re: each help

2007-11-18 Thread rayfidelity
THANK YOU I've been struggling with this last 4 days! Thank you very much! On Nov 17, 8:42 pm, Flesler <[EMAIL PROTECTED]> wrote: > Since jQuery 1.2, [EMAIL PROTECTED] was replaced for [attr=value] that > could be.. anyway you can do: $('input:text') > > also, I think what you meant was: > >

[jQuery] Re: each help

2007-11-18 Thread Flesler
Since jQuery 1.2, [EMAIL PROTECTED] was replaced for [attr=value] that could be.. anyway you can do: $('input:text') also, I think what you meant was: function test(){ $("div.row").each(function(){//div.row must match the rows that contain each set. var $inputs = $('input',this);

[jQuery] Re: each loop selects to much

2007-10-31 Thread hans
Ahh that explains clearly why my expectations were so different from the results. Thank you both Glen and Dave!

[jQuery] Re: each loop selects to much

2007-10-25 Thread Dave Methvin
> $("#testtable tr").each(function(t){ That selector says to select any tr that is a descendant of #testtable. And it did! The tr in nested tables are descendants of the original table too, but they're not direct children. If you just want the tr elements in the outer table, try a selector like

[jQuery] Re: each loop selects to much

2007-10-25 Thread Glen Lipka
I whipped up a demo. http://www.commadot.com/jquery/nestedTables.php In the code comments is an "each" version that does the same thing. Glen On 10/25/07, hans <[EMAIL PROTECTED]> wrote: > > > Hello, > > I am trying to loop through all rows of a table that has a table > inside. I expected jquery

[jQuery] Re: "each()" and "this" problems

2007-09-24 Thread george.gsgd
> // VERSION 2 supposed to remove bad branches > // instead removes ALL branches > var this2 ; > $(objectfoo).children().each(function(ichild){ > this2 = this ; // buffer > if($(this2).find('a').not(keeplist)){$(this).remove();}}) > Well to try and break it down,

[jQuery] Re: .each "this" inside class

2007-08-14 Thread Rob Desbois
Eridius, I believe (but could be wrong) that even if you are in a class, from within the .each() function parameter, you're no longer within that context but within the context of iterating through the DOM nodes so 'this' should still be the DOM node: function some_class_function() { >// in t