Oh, neat idea for some quick prototypes if you'll be using this a lot.
String.prototype.is = function(){ var rgx = new RegExp('^' +
[].slice.call(arguments).join("|") + '$'); return rgx.test(this) }
Should mimic: /^A|B|C$/.test( $('#price_group_lesson').val() );
Called by: $('#price_group_less
That's some cool code. Thanks Guys!
-Roman
On Jan 21, 11:49 pm, Ricardo Tomasi wrote:
> var abc = /^A|B|C$/.test( $('#price_group_lesson').val() );
> $('#price_group_lesson_yes')[abc ? 'slideDown' : 'slideUp']('fast')
>
> (it could be a one-liner but I splitted it for readability)
>
> A simple
Good stuff, Ricardo!
Rick
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> Behalf Of Ricardo Tomasi
> Sent: Wednesday, January 21, 2009 11:50 PM
> To: jQuery (English)
> Subject: [jQuery] Re: Syntax similar to IN in SQL
var abc = /^A|B|C$/.test( $('#price_group_lesson').val() );
$('#price_group_lesson_yes')[abc ? 'slideDown' : 'slideUp']('fast')
(it could be a one-liner but I splitted it for readability)
A simpler improvement you could have done:
var p = $('#price_group_lesson').val();
if ( p == 'A' || p == '
> I am sure there is something in javascript
> or jquery where I can say $
> ('#var').attr('value').in("A","B","C")
You could do this:
/^(A|B|C)$/.test(('#var').attr('value'));
You can also use the i (ignore case) flag with that which is handy.
5 matches
Mail list logo