Reputation: 1594
For example, if i had a variable in javascript
var nombre;
onclick="nombre='someValue'"
and somewhere along in my code this javascript variable's value is changed like above, could I set the value of that variable to be the class name in the jquery selector so it would be like
$('.someValue').show()
Upvotes: 2
Views: 68
Reputation: 9080
Yes you can:
$('.' + nombre).show();
This assumes that your variable nombre
has such scope that it is available in your jQuery code too.
Upvotes: 4