嗨,我有另一个问题刚刚由 stackoverflow 的成员解决,非常感谢他们的及时回复和专业。下面是我发现 ibox 根本没有调用的 JS 代码。
(function($) {
$.fn.ibox = function() {
// set zoom ratio //
alert("asdfas");
resize = 20;
////////////////////
var img = this;
img.parent().append("<div id='ibox' />");
var ibox = $("#ibox");
var elX = 0;
var elY = 0;
img.each(function() {
var el = $(this);
el.mouseenter(function() {
ibox.html("");
var elH = el.height();
elX = el.position().left - 6; // 6 = CSS#ibox padding+border
elY = el.position().top - 6;
var h = el.height();
var w = el.width();
var wh;
checkwh = (h < w) ? (wh = (w / h * resize) / 2) : (wh = (w * resize / h) / 2);
$(this).clone().prependTo(ibox);
ibox.css({
top: elY + "px",
left: elX + "px"
});
ibox.stop().fadeTo(200, 1, function() {
$(this).animate({top: "-="+(resize/2), left:"-="+wh},400).children("img").animate({height:"+="+resize},400);
});
});
ibox.mouseleave(function() {
ibox.html("").hide();
});
});
};
});
$(document).ready(function() {
$("#clickMe").click(function () {
alert("Me");
});
var html = "";
var num = 1;
for (var idx=0; idx<100; idx++)
{
if( num == 4) num = 1;
html += "<img src='image/img" + num + ".jpg' class='grayscale' />";
num ++;
}
$("#images").html(html);
$("#images img").ibox();
});
我在这里错过了任何呼叫步骤吗?请帮忙。谢谢