Help with assigning an attr to a variable

Help with assigning an attr to a variable

Hi.

Ive just started taking some javascript and jquery lessons and we have been assigned a little project: an image galery.

so i came up with the following:

when i click any button with the class "thumbnail", i want to set the src of the thumbnail to a variable, and then set that variable as the src of the main image (#imggrande"). 

I am having trouble finding an answer on how to assign the src of the image clicked to the variable.


$(".thumbnail").on("click", function() {

var imgpath = ?????

$("#imggrande").attr("src", imgpath)

});



As i am typing this, i just figured the variable is pretty redundant, i could just put whatever i would type to assign the variable in the src attribute, right?

is there is a simpler way to do this?


thank you