In jQuery we usually use, for example:
var content = $('tr#someid td').find('div').html();
var content = $('tr#someid div').has('p').text();
var content = $('tr#someid td:eq(1) div').html();
Is it possible to make the right part of dollar sign $ dynamic?
// Pattern Array
var pattern = [
"('tr#someid td').find('div').html()",
"('tr#someid div').has('p').text()",
"('tr#someid td:eq(1) div').html()"
];
var contents = "";
for (i=0; i<pattern.length; i++) {
/*
* I WANT TO GRAB THE ELEMENTS HERE!
* SOMETHING LIKE:
*/
var dynamic_var = pattern[i];
contents += $dynamic_var;
}
Is it possible?
So the problem is:
- Can we make the Variable Variable in jQuery Selector?
- Like:
$_______________;? - The blank
_________will be a dynamic pattern variable
May be you could use
eval, please check the demoNot really sure if this will serve your purpose but hope this help.