Drkosh Drkosh - 2 months ago 6
jQuery Question

How to dynamic select element with JQuery by id

I need to dynamic select element with JQuery, I get in code id of element. How to do that ?
I've tried:

var sel='\'#'+id+'\'';
var elem+$(sel);


but it doesn't work ( id is string id of element).

Answer

You would use code such as

var ID = 'whatEver';
$('#' + ID).action();

You would then be able to use that to select whatever element you are after.

Comments