how do you transfer a value from a text() to an image SRC

how do you transfer a value from a text() to an image SRC

hi everyone.

i am using the text()  function to retrieve values from an onclick function. i now want to transfer this value to the SRC on an image tag.

  1. var base = $(this).data('link- to-image');
  2. <img src="base" >

 
i am slightly confused how to do this; for example in PHP i would simple place the returned values into an variable  and then place the variable into the SRC.

i want to do something similar in jquery . I will however need to swap out the values if the user clicks the onclick  button again. 

Can sombody please advise me how to do this.

warm regards

Andreea