下面的代码适用于“mousemove”,但我希望图像在页面加载时显示,而我所做的任何更改都不会使图像在页面加载时显示。任何帮助是极大的赞赏!谢谢伊恩
$(document).ready(function () {
$("body").mousemove(function () {
$("li.fsn-level-1").each(function () {
var imgCount = $(this).children("span").first().children("img").length;
if (imgCount < 2) {
$(this).children("span").first().prepend("<img id='imgPlus' src='images/plus.png' style='display:inline' />");
$(this).children("span").first().prepend("<img id='imgMinus' src='images/minus.png' style='display:none' />");
}
var closed = $(this).hasClass("closed");
var open = $(this).hasClass("open");
var first = !closed && !open;
if (first) {
$(this).removeClass("open")
$(this).removeClass("closed").addClass("closed");
var sub = $(this).children("ul");
if (sub.length) {
sub.hide();
}
var plus = $(this).children("span").first().find("img[id='imgPlus']");
if (plus.length)
plus.show();
var minus = $(this).children("span").first().find("img[id='imgMinus']");
if (minus.length)
minus.hide();
}
$(this).unbind('hover').bind('hover', function () {
CloseAllSubMenu();
var closed = $(this).hasClass("closed");
var open = $(this).hasClass("open");
var first = !closed && !open;
if (first || closed) {
$(this).removeClass("closed");
$(this).removeClass("open").addClass("open");
var sub = $(this).children("ul");
if (sub.length) {
sub.show();
}
var plus = $(this).children("span").first().find("img[id='imgPlus']");
if (plus.length)
plus.hide();
var minus = $(this).children("span").first().find("img[id='imgMinus']");
if (minus.length)
minus.show();
}
if (open) {
$(this).removeClass("open")
$(this).removeClass("closed").addClass("closed");
var plus = $(this).children("span").first().find("img[id='imgPlus']");
if (plus.length)
plus.show();
var minus = $(this).children("span").first().find("img[id='imgMinus']");
if (minus.length)
minus.hide();
}
});
});