Great to follow this thread...
Very concise and elegant jQuery code!! thanks
- Original Message -
From: Charlie
To: jquery-en@googlegroups.com
Sent: Wednesday, June 24, 2009 1:02 PM
Subject: [jQuery] Re: Selecting the first of two td's in a tr
actually i learned h
actually i learned how to add the (..., this) from another post
on this list
i struggeled at first learning how to use "THIS" when creating a
selector
I always wanted it to work like a parent child regular selector and
kept trying a lot of things like:
$(this "li").hide();
or $((this
Sweet, thanks Charlie...
Charlie, how did you find out about: $("td:first",this)? In the
jquery docs i havent seen the ",this" I'm assuming that adding that
filters out the first td of each tr, I'd be interesting in knowing
more about how to filter things. Looks like I could make most of my
code
No prob! Looks like you are real close to what Charlie just posted
that works great, except that it applies to every table on the page.
Once I added the table id it was perfect!
$("table#mytableid tr").each(function() {
$("td:first",this).attr("align","right");
});
On Jun 24, 11:31 am, Matthew
sorry about the error, replace "break;" with "return false;" Yeah,
ignore the last code then. Try this, I'm trying to find a way of doing
this cleanly so I guess we are both learning together haha
$("table tr").each(function(){
$(this).children(":first").attr("attribute","value");
})
This worked great. Thx to both of you guys!!!
On Jun 24, 11:25 am, Charlie wrote:
> this works and is far shorter and sweeter:
> $("tr ").each(function() {
> $("td:first",this).css("color","red");
> });
> MikeyJ wrote:Looks like your first two offerings throw this error in Firebug:
this works and is far shorter and sweeter:
$("tr ").each(function() {
$("td:first",this).css("color","red");
});
MikeyJ wrote:
Looks like your first two offerings throw this error in Firebug:
"unlabeled break must be inside loop or switch"
Your last example works but it only
Looks like your first two offerings throw this error in Firebug:
"unlabeled break must be inside loop or switch"
Your last example works but it only works on the first TR and it
affects both TD's in that TR. ??
On Jun 24, 10:59 am, Matthew wrote:
> yeah haha let me re-do:
>
> $("table#id tr:fi
yeah haha let me re-do:
$("table#id tr:first-child").each(function(){
$(this).attr("attribute","value");
});
try that. I am thinking that the tr:first-child should return the TD
for every TR in the table. Im not sure how this will work if you have
nested tables. I'm a
Didn't see your latest post before I posted! I'll give it a spin. Thx!
On Jun 24, 10:48 am, Matthew wrote:
> actually now that I thought about it my first post may not work...
> because you'd have to first get all the tr's then take each tr and
> find the first two td's. You can try my first res
Thx Matthew! Great explanation.
I probably should have worded one thing a bit differently...I'd like
to set this attribute for "the first TD in each TR for EVERY TR in an
entire table". I'm sure this changes things a tiny bit?
Mike
On Jun 24, 10:43 am, Matthew wrote:
> when you use this code $
actually now that I thought about it my first post may not work...
because you'd have to first get all the tr's then take each tr and
find the first two td's. You can try my first response, if not try
this:
$("table tr").each(function(){
var counter = 0;
$(this).children
when you use this code $("tr td") it would create an array of all
those td's in the tr. So then we just need to cycle through the first
two and set the attribute then break the cycle.
var counter = 0;
$("tr td").each(function(){
$(this).attr("attribute","value");
counter++;
13 matches
Mail list logo