views:

29

answers:

2

I want to invoke a creation of div with certain class just below the invoke button, how can I do that most efficiently with jquery?

+1  A: 

use the after method in the button's click handler

$(input_btn).click(function() {
    $(this).after('<div class="myclass">content</div>')
})
maid450
this however works
Gandalf StormCrow
+2  A: 
$('.button').click(function(){
    $('<div />', {class:'myClass'}).insertAfter(this);
});
Kobi
@Kobi I get error on IE8 while using this
Gandalf StormCrow
@Gandalf StormCrow: is seems `class` is a reserved word, it should be `'class':'myClass'`.
Kobi