can you please help me with this :
I am trying to click three different buttons with different ids, but based on a string variable name in javascript like :
function my_custom_js_func(){
jQuery( "#listViewer" ).click();
};
but this will always click the button with id listViewer
i have a variable :
var viewTog = "List";
or : var viewTog = "Grid";
I want to do something like this :
function my_custom_js_func(){
if (viewTog == "List") {jQuery( "#listViewer" ).click();};
if (viewTog == "Grid") {jQuery( "#gridViewer" ).click();};
};
but it doesn't work, I am using the variable viewTog as a memory.
thank you !
Aucun commentaire:
Enregistrer un commentaire