[jQuery] Re: Find text (nodes) within an element?

2009-06-10 Thread Karl Swedberg
quick note of caution about this one: $('label').text().substr(-1) === "F"; .substr() won't work with a negative index in IE6 and 7 (maybe 8, too?). It'll return the full string. Use .slice(-1) instead. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On J

[jQuery] Re: Find text (nodes) within an element?

2009-06-10 Thread ldexterldesign
Awesome, thanks guys. I haven't tested it yet, but a Twitter follower of mine added this earlier, just for everyone's reference: $('label').text().slice(-1)=="F" Cheers again, I'll check all your examples out tomorrow. L On Jun 11, 12:23 am, mkmanning wrote: > Here's a couple other ways: > >

[jQuery] Re: Find text (nodes) within an element?

2009-06-10 Thread mkmanning
Here's a couple other ways: /F$/.test($('label').text()); or $('label').text().substr(-1) === "F"; On Jun 10, 3:24 pm, ldexterldesign wrote: > Easy guys, > > A B C D E F > > Anyone got any tips on how to find out if the last letter of my label > is 'F'? > > Cheers, > L

[jQuery] Re: Find text (nodes) within an element?

2009-06-10 Thread Mauricio (Maujor) Samy Silva
$(document).ready(function(){ var string = $.trim( $('label').text() ) var lastIndex = string.length - 1 if ( string.charAt(lastIndex) == "F" ) { alert('BINGO!') } else { alert('FAIL!') } }); Maurício -Mensagem Original- De: ldexterldesign Para: jQuery (En