我在我的網站中使用Drupal 7和Views模塊。並希望顯示我當前的縮略圖圖片上的編號。搜索計算器,找到這個代碼:如何在javascript中獲取當前圖像的編號
HTML CODE:
<img src="http://www.ambuvet.com/images/white-cat.jpg" />
<img src="http://www.biobest.co.uk/assets/images/diagnostics/cats.jpg" />
<img src="http://animal.discovery.com/guides/atoz/gallery/cat.jpg" />
JAVASCRIPT CODE:
window.onload = function() {
for (var i = 0; i < document.images.length; i++) {
var image = document.images[i];
image.setAttribute("index", i + "");
image.onclick = function() {
var index = this.getAttribute("index");
alert("This is image #" + index);
};
}
};
看到此鏈接:http://jsfiddle.net/uUF8x/
但我不知道,我怎麼能在當前縮略圖上取代對GET號此代碼。謝謝。
總是交相關代碼**在問題本身**,不只是鏈接到它。爲什麼:http://meta.stackexchange.com/questions/118392/add-stack-overfow-faq-entry-or-similar-forputing-code-in-the-question – 2012-04-03 08:39:55
人們如何幫助你,如果你不要說你的「想要」? – tusar 2012-04-03 08:44:14
編輯我的帖子,對不起。 – Karmacoma 2012-04-03 08:45:49