I\'m trying to create a div and give him a class but it doesn\'t work. Could anybody help me?
$(document).ready(function() {
$(\'input[type=checkbox]\').each(fun
$(document).ready(function() {
$('input[type=checkbox]').each(function() {
$(this).after($('<div />', {
class: 'test',
text: "a div",
click: function(e){
e.preventDefault();
alert("test")
}}));
});
});
http://jsfiddle.net/yF9pA/1/
try class
instead of className
$('input[type=checkbox]').each(function() {
$(this).after('<div></div>').addClass('test')
.filter('div').html('a div')
.click(function() {
alert('Handler for .click() called.');
}).end()
.appendTo('this');
});
Should work :)
use "class" instead of className
$('<div />', {
"class": 'test',
text: "a div",
click: function(e){
e.preventDefault();
alert("test")
}})
$('<div>', { 'class': 'your_class' })
.load('HTML Structure', CallBackFunction())
.appendTo(document.body);