EDIT: I would like to avoid doing something like this:
var str = 'Hello';
if ( str == 'Hello') {
alert(str);
}
I would rather do:
var str = 'Hello';
$(str).filter(':contains("Hello")').each(function(){
alert(this)
});
I’ve tried a lot of things:
$(str).text().method1().method2().method3();
$(str).val().method1().method2().method3();
$(str).contents().method1().method2().method3();
Nothing worked. Is it possible to do this?
Thank you for your time.
Kind regards,
Marius
Put the value in an array, they you can use the
grepmethod to filter out the items in the array that matches a criteria:You can also make a plugin to make it more like the code that you wished for:
Usage: