[英]Jquery not working in IE 9 or older
Forgive me for not being the best JQuery programmer but I have run into an issue. 原谅我不是最好的JQuery程序员,但遇到了一个问题。 My Jquery runs perfectly in FF/IE10 but that's about it.
我的Jquery在FF / IE10中完美运行,仅此而已。 I am not sure as so why, but here is my code.
我不确定为什么,但是这是我的代码。 Please help if possible!
如果可以的话请帮忙!
The textbox "custom-url" does not .hide on the load, as well and .show when the dropdown list is changed to option "custom" like it does on other browsers. 文本框“ custom-url”也不会隐藏在加载中,当下拉列表更改为选项“ custom”时也不会隐藏在.show中,就像在其他浏览器中一样。
I am currently using jquery-1.5.1 and here is the html for my text box: 我目前正在使用jquery-1.5.1,这是我的文本框的html:
<input type="text" id="custom-url" style="width:220px;"/>
This next part is only specific to the current page so it is imported into page that uses it. 下一部分仅特定于当前页面,因此将其导入到使用它的页面中。
<script type="text/javascript">
$(document).ready(function () {
"use strict";
$("#custom-url").hide();
});
$("select#url-list").change(function () {
"use strict";
var selectedItem = $("option:selected", $(this)),
selectedValue = selectedItem.val();
$("#url").val(selectedValue);
if (selectedValue === "custom") {
$("#custom-url").show();
} else {
$("#custom-url").hide();
}
});
$("form").submit(function () {
"use strict";
var selectedItem = $("select#url-list option:selected"));
var selectedvalue = selectedItem.val();
if (selectedvalue === "custom") {
$("#Url").val($("#custom-url").val());
} else if (selectedvalue === '') {
} else {
$("#Url").val(selectedItem.val());
}
});
</script>
This next part is global specific so it is imported into master. 下一部分是全局特定的,因此将其导入主数据库。
<script src="@Url.Content("~/Scripts/MyScripts.js")" type="text/javascript"></script>
$(document).ready(function () {
var str = $('iframe').attr('src');
var substr;
var current_tab = "";
$("#topNav ul:first-of-type li:last-child").hover(function () {
$(this).addClass("elementHovered");
}, function () {
$(this).removeClass("elementHovered");
});
if (str == undefined) {
// alert($("ul:first-of-type li:last-child").parent().html());
current_tab = "Admin";
$("#topNav ul:first-of-type li:last-child").children().addClass("elementHovered");
}
else {
substr = str.split('/');
var str = "";
var i;
for (i = 0; i < substr.length; ++i) {
str = str + "subtri[" + i.toString() + "]" + substr[i] + " ";
}
$('#topNav ul:first-of-type').children('li').each(function () {
if (substr[2] == "prototype.sunoconet2012.com") {
current_tab = "Documents";
}
else if (substr[3] == "admin") {
current_tab = "Home"
}
else {
switch (substr[1]) {
case 'contracts':
current_tab = "Account Information"
break;
case 'financials':
current_tab = "Financial"
break;
case 'pricing':
current_tab = "Pricing"
break;
case 'operations':
current_tab = "Operations";
break;
case 'support':
current_tab = "Support"
break;
case 'admin':
current_tab = "Support"
break;
case 'SunocoUniversity':
current_tab = "Training";
break;
case 'onlinetraining':
current_tab = "Training";
break;
default:
current_tab = "Administration";
break;
}
}
if (current_tab == $(this).text()) {
// alert("current_tab: " + current_tab + " this.text: " + $(this).text());
// alert("substr[1] = " + substr[1] + "substr[2] = " + substr[2] + " substr[3] = '" + substr[3] + "' current_tab = " + current_tab + " $(this).text() = " + $(this).text()); // "this" is the current element in the loop
$(this).children().css("background-color", "#4D77A7");
$(this).children().css("color", "white");
}
});
}
});
更新到Jquery 1.9.1可以解决问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.