$(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
Here's a couple other ways:
/F$/.test($('label').text());
or
$('label').text().substr(-1) === F;
On Jun 10, 3:24 pm, ldexterldesign m...@ldexterldesign.co.uk wrote:
Easy guys,
labelA B C D E F/label
Anyone got any tips on how to find out if the last letter of my label
is 'F'?
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 michaell...@gmail.com wrote:
Here's a
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
4 matches
Mail list logo