replace - Set a variable as the ID of a clicked div, then modify that variable to select a different div -
i have multiple images , when click on 1 want code set specific images id ("image_select_1") variable. want modify variable removing text "select" (with underscores on either side of it) middle of variable becomes "image1". use variable target different div , fade in. here code have it's of course, not working.
var foo; $('.game_selection_image').click(function() { foo = $(this).attr("id"); foo = foo.replace("_select_",""); $("#" + foo).fadein(500); }); any appreciated, thank :)
watch variables
$("div.game_selection_image").click(function(e) { var foo = $(this).attr("id"); foo = foo.replace("_select_",""); $('#' + foo).fadein(500); });
Comments
Post a Comment