Every time I click on a button
<button class="xx type="submit" id="add_football">Add</button>
I want to add a image(<img src="img/door-right.png">
)inside the
<div class="ball_footballbox"><img src</div>
How do I do that with jQuery?
Every time I click on a button
<button class="xx type="submit" id="add_football">Add</button>
I want to add a image(<img src="img/door-right.png">
)inside the
<div class="ball_footballbox"><img src</div>
How do I do that with jQuery?
Try this
$(".ball_footballbox").append('<img src="img/door-right.png">');
wrap this in a function and call this function on click of button action.
try like below... it will work
HTML :
<button class="xx" type="submit" id="add_football">Add</button>
<div class="ball_footballbox"></div>
JQuery :
$("#add_football").click(function() {
$('.ball_footballbox').prepend('<img id="theImg" src="img/door-right.png" prepended="yes"/>')
});
Fiddle : http://jsfiddle.net/RYh7U/73/
Take a look at this Demo this will help you to get the answer for adding images.
$("#add_football").click(function(){
$('<img src="http://jqfaq.com/wp-content/uploads/logo_v1.png">').appendTo($(".ball_footballbox"));
});
i hope this will help you more.