How to use Jquery variable as css selector?
For instance,
I do not know how to use value of variable as Jquery/css selector.
For instance,
Code:
<script>
$(document).ready(function(){
var ind='th78'; //database row index
var classname='highlight ' + ind;
spanNode.className = classname; // set css
$(".highlight.ind").append("text from database with id=ind");
})
// this does not work because there should be not word "ind", but value of variable ind. How to select value of variable ind?
//OR
var spanNode = document.createElement('span');
var ind='th78'; //database row index
spanNode.id=ind;
$("[#id=ind]").append("text from database with id=ind");
//This also does not work, because instead of ind, i have to compare with variable ind. How to use value of variable ind?
</script>
Comment