下面的代码工作正常“鼠标移动”,但我想要的图像显示在页面加载,并没有什么我已经改变使图像在页面加载显示。 任何帮助,非常感谢! 感谢 伊恩如何让JQuery在页面加载时加载图像?
$(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();
}
});
});
你的意思是移动$(本)。儿童( “跨度”)第一()前置( “”)。 $(this).children(“span”)。first()。prepend(“”);高于document.ready,如果是这样,我尝试了,它不起作用。顺便说一下你的假设是正确的。 Thx – user2213017 2013-03-26 21:29:27