我有一些js代码我试图得到它所以当cat2发生它激活模态
所以我试过if(cat2){$('#myModal')。modal('show')};但这对我不起作用
我看了看但还没有找到答案
这是我找到代码http://www.hungrypiranha.org/make-a-website/html-quiz
的地方 $(document).ready(function()
{ $("#results").click(function() {
if (!$("input[@name=q1]:checked").val()
) {
alert("You're not done yet!");
}
else {
var cat1name = "1";
var cat2name = "none";
var cat1 = ($("input[@name=q1]:checked").val() != "a");
var cat2 = (!cat1); var categories = [];
if (cat1) { categories.push(cat1name) };
if (cat2) { categories.push(cat2name) };
var catStr = 'You answered the following questions incorrectly: ' + categories.join(', ') + '';
$("#categorylist").text(catStr);
$("#categorylist").show("slow");
if (cat1) { $("#category1").show("slow"); };
if (cat2) { $("#category2").show("slow"); };
{ $("#closing").show("slow"); };
}
});});
答案 0 :(得分:0)
如果你想在JS中扩展bootstrap的模态功能,最好的解决方案是使用这样的插件
你可以像这样把它包围起来
bootbox.dialog({
message: "I am a custom dialog",
title: "Custom title",
buttons: {
success: {
label: "Success!",
className: "btn-success",
callback: function() {
alet"great success");
}
},
danger: {
label: "Danger!",
className: "btn-danger",
callback: function() {
alert("uh oh, look out!");
}
},
main: {
label: "Click ME!",
className: "btn-primary",
callback: function() {
alert("Primary button");
}
}
}
});