在我的 .NET 项目中,我在 HTML 页面中使用了一个 Button,它带来了隐藏的<div>
. <div>
其中包含插入公司的表单。
HTML:
<div class="top-div-where-is-my-ADD-button">
<h2>
Search:
<input type="text" id="search" />
<div id="divADD" onclick="AddCompany()">
<span>Add Company</span></div>
</h2>
</div>
<div id="hide" style="visibility: hidden; height: 0px; padding-bottom: 10px;">
<table id="CompanyDetails" class="company" style="width: 100%; text-align: center;">
.........
</div>
JavaScript:
function AddCompany() {
HideCompany();
$(hide).css({ visibility: "visible", height: "auto" });
var a = document.getElementById("divbuttonSaveCompany");
a.onclick = InsertCompany;
}
function InsertCompany() {
var a = document.getElementById("Name").value;
var b = document.getElementById("Address").value;
var c = document.getElementById("Country").value;
var d = document.getElementById("Phone").value;
var e = document.getElementById("Fax").value;
var f = document.getElementById("Email").value;
var gg = document.getElementById("Contact");
var g = gg.options[gg.selectedIndex].value;
$.ajax({
url: '@Url.Action("AddCompany", "Company")',
data: { nameCompany: a, address: b, country: c, phone: d, fax: e, email: f , contact: g},
dataType: "html",
type: "POST",
error: function () {
alert("error");
},
success: function (data) {
alert("Company was successfully added! ");
$("#all").html(data);
}
});
}
function HideCompany() {
$(hide).css({ visibility: "hidden", height: "0" });
$("#Name").val("");
$("#Address").val("");
$("#Country").val("");
$("#Phone").val("");
$("#Fax").val("");
$("#Email").val("");
}
所以基本上在 IE 中,当我按下 AddCompany 按钮时,隐藏的会<div>
出现,但在 FF 中不会。
有谁知道我需要做什么来解决这个问题?