Assuming you want only the image to be displayed within the #demo
(and also assuming you want this to happen on form submission):
$('form').submit(
function() {
$('#demo').html('<img src="path/to/image.jpg" />');
return false;
}
);
If, instead, you want to add an image to the #demo
(though still assuming this is on form submit):
$('form').submit(
function() {
$('<img src="path/to/image.jpg" />').appendTo('#demo');
return false;
}
);
Just a quick note, but it seemed worth mentioning:
- the above all need to be enclosed by a
$(document).ready(/*...*/)
(or equivalent).
- the
onClick
inline click-handler is no longer required if the above is used, and might actively complicate matters if it remains in place.