0
我想添加一個圖像到我目前的iframe數字鍵盤。我fairley新jquery,所以我不知道我可以添加按鈕圖像,我做了我的jQuery的。任何幫助將不勝感激。我的代碼如下所示:jquery numpad image
// Get a numpad button
var GetButton = function(value, fn)
{
var button = document.createElement("input");
button.type = "button";
button.value = value;
button.style.width = "80px";
button.style.height = "70px";
button.onclick = fn;
return button;
};
// Attach the Numpad control to the page.
// Create the HTML elements and bind events
var Initialize = function()
{
div = document.createElement("div");
div.style.position = "absolute";
div.style.zIndex = 999999;
if(randomize === true)
{
var rem = [0,1,2,3,4,5,6,7,8,9];
var idx;
var pos = 0;
while(pos < 12)
{
if(pos != 9 && pos != 11)
{
idx = Math.floor(Math.random() * (rem.length));
button = GetButton(rem[idx], (function (value)
{
return function() { target.value += value; }
})(rem[idx]));
div.appendChild(button);
rem = rem.Remove(idx);
}
else
{
if(pos == 9)
{
button = GetButton("C", function() { target.value = ""; });
div.appendChild(button);
}
}
pos++;
}
}
else
{
for(var i=1; i<=9; i++)
{
button = GetButton(i, (function (value)
{
return function()
{
target.value += value;
}
})(i));
div.appendChild(button);
}
// Clear button
button = GetButton("", function()
{
target.value = "";
});
div.appendChild(button);
// 0 button
button = GetButton(0, (function (value)
{
return function() { target.value += value; };
})(0));
div.appendChild(button);
// Close button
button = GetButton("", function()
{
target.value = "";
});
div.appendChild(button);
}
div.style.width = "250px";
iframe.style.position = "absolute";
iframe.frameBorder = 0;
document.body.appendChild(iframe);
document.body.appendChild(div);
Hide();
};
請只顯示該項目的相關代碼。這要求我們篩選一個文件太大。 – Ohgodwhy 2012-08-06 14:32:58
你問如何製作HTML按鈕? – epascarello 2012-08-06 14:41:51
我編輯了按鈕部分的代碼。我有按鈕作爲PNG圖像。我只是不知道如何將它們添加到我的jQuery代碼。 – 2012-08-06 14:56:34