I have a with the rel=\"example.jpg\". I want the button to load the image in my #area DIV, just after
rel=\"example.jpg\"
#area
Change your code to this:
$(document).ready(function(){ $("button").click(function(){ var imgUrl = $(this).data('rel'); $("#area").html(""); }); }); Click Me
Fiddle: http://jsfiddle.net/x3QdU/4/