0
A
回答
1
使用純DOM腳本,並像jQuery沒有幫手框架,總得灰塵有些東西我還沒有在一段時間使用!
這就是說這裏雅去。必須在頁面加載後放置。 (或刪除最後一個「showCredit();」線,並將其放在你的身上onload。
注意你需要改變這一點,我只是把「源」放在文本中,其他屬性和樣式是給你。
function showCredit(){
//find all image tags we want
var elements = document.getElementsByTagName('img')
//iterate through them
for(var i=0; i<elements.length;i++){
//bind the onclick function to all image tags
elements[i].onclick=function(){
//create the new div
var el = document.createElement('div')
//alter this to be whatever text you want
var text = document.createTextNode('Source = '+this.getAttribute('src'));
//alter this if you're going to have more than one clickable div
el.id = 'test';
//add the text to the div
el.appendChild(text);
//add the new div after the image tag
this.parentNode.insertBefore(el, this.nextSibling);
//set a timer to find the element we've named "test" and remove it
window.setTimeout(function(){
var element = document.getElementById('test');
if(element){
element.parentNode.removeChild(element);
}
}, 4000);
}
}
}
//execute the function (bind all images)
showCredit();
+0
大代碼,以完成這裏所述OP請求是標題和大小的行:document.createTextNode( '源= '+ this.getAttribute(' SRC')+ ',title:'+ this.title +',size:'+ this.offsetWidth +'x'+ this.offsetHeight); – 2010-11-12 23:09:59
相關問題
- 1. 顯示圖像幾秒鐘
- 2. 顯示和刪除圖像幾秒鐘
- 3. 如何顯示視圖3秒鐘,然後隱藏它?
- 4. 在JavaScript上方顯示圖像上方几秒鐘的圖像?
- 5. 使用計時器顯示文本3秒鐘?
- 6. 在cli中每3秒鐘逐行回顯文本
- 7. 如何顯示圖像和描述類別的widget WordPress的
- 8. 如何分別顯示模塊中的文章描述和圖像joomla
- 9. 如何顯示一個圖像五秒鐘然後顯示另一個(Android Studio)
- 10. 如何顯示jmx MBean的類描述,屬性描述和操作描述
- 11. 如何顯示用戶在Django模板中寫入的圖像描述
- 12. SQL:在文本中顯示描述而不是位值
- 13. WordPress:爲非圖像媒體顯示標題或描述,如PDF
- 14. 描述文本在文本字段中?
- 15. 如何暫停顯示器幾秒鐘?
- 16. 如何顯示類別描述?
- 17. 幾秒鐘後顯示警告視圖
- 18. 每秒鐘執行並顯示圖形
- 19. 如何在RSpec中未描述的示例上顯示失敗?
- 20. 如何用C++或python從圖像中讀取圖像描述?
- 21. 如何在CSS中編寫文本,如在圖像中顯示?
- 22. PasswordStrength Extender未顯示文字描述
- 23. 在視圖上顯示圖像1秒
- 24. 如何使用opencv中的描述文件裁剪圖像
- 25. pg_query顯示/描述表
- 26. og:描述未顯示
- 27. 只顯示分鐘和秒鐘0
- 28. jQuery ajax加載 - 顯示加載圖像一分鐘。 1秒
- 29. 如何在RSS Feed中顯示ListView中的鏈接和描述?
- 30. 問題與描述顯示畫廊圖像Keystone.js
通常你會得到幫助這裏固定的東西你不工作。你嘗試過什麼? – lincolnk 2010-11-12 19:44:36
功能showCredit(whichpic,X,Y){ \t VAR源= whichpic.getElementsByTagName (「img」); \t var title = source.getAttribue(「src」); \t var size = source.getAttribute(「width」,「height」); \t \t document.write(title + size); \t } \t \t 功能prepareTimers(){ \t \t \t \t的setTimeout(showCredit,4000); \t \t \t} \t \t \t的window.onload = prepareTimers – 2010-11-12 19:52:25