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
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:
>
>
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
$(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
4 matches
Mail list logo