i want change the source of the images using javascript variable, as in i have a variable “vp_active_row_count” which shows by number which ball is active. (“_a”=means active image source).
But i can’t find any object using that lower javascript code. Is it even possible?
Javascript
var vp_active_row_count=2;
var test = '"#'+vp_active_row_count+'"';
$(test).attr('src','assets/img/vp_a.png');
HTML
<div class="vp_balls" style="width: 48px;">
<img id="1" src="assets/img/vp_a.png">
<img id="2" src="assets/img/vp.png">
<img id="3" src="assets/img/vp.png">
</div>
No need to quote twice! Quotes are for telling JS that this is a string, but jQuery doesn’t need the extra pair