首页 > bootstrap中的madal咋么放在js中

bootstrap中的madal咋么放在js中

bootstrap中的madal咋么放在js中


$modal = $alert = $('<div class="modal fade alert-modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">\
            <div class="modal-dialog modal-sm" style="width:700px;">\
                <div class="modal-content alert-modal-content" style="top:40%;margin-top:-103px;background-color:#f3f3f3;">\
                    <div style="padding:20px 0 19px;font-size:21px;color:#c2c0be;" class="tc f20 fcg f16">Notice</div>\
                    <img  src="/images/scenic_chacha.png" style="top:21px;right:17px;opacity:0.6;" class="cp pa alert_img_close">\
                    <div class="message_alert f16 fcg" style="margin-left:31px;padding:41px 45px 0;width:636px;height:136px;border:1px solid #eee;border-radius:3px;background-color:white;">'+msg+'</div>\
                    <button class="alert_button" style="margin:35px 31px 40px 0;width:185px;height:50px;border-radius:3px;font-size:20px;">OK</button>\
                    <div class="cb"></div>\
                </div>\
            </div>\
        </div>');


$('body').append($modal);
$modal.modal('show');

1 将HTML转换成字符串,字符串换行的时候记得使用转义符 "";
2 将字符串插入到某个容器中;
3 调用.show()


bootstrap本来自带操作model的属性:


$('#myModal').modal('show');
$('#myModal').modal('hide');

使用Javascript字符串及字符串拼接

var tpl = '<div class="modal">...</div>';
【热门文章】
【热门文章】