jQuery: Quick question. How to select string variable?
- by user317563
Hello world,
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