How to create div with class

本秂侑毒 提交于 2019-12-02 20:07:27

use "class" instead of className

$('<div />', {
        "class": 'test',
        text: "a div",
        click: function(e){
            e.preventDefault();
            alert("test")
        }})
$(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/

 $('<div>', { 'class': 'your_class' })
                 .load('HTML Structure', CallBackFunction())
                 .appendTo(document.body);
$('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 :)

try class instead of className

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!