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. 如何顯示圖像幾秒鐘並關閉它?
- 8. 如何顯示圖像和描述類別的widget WordPress的
- 9. 如何分別顯示模塊中的文章描述和圖像joomla
- 10. TableView到detailview:在DetailView中顯示圖像和描述iphone sdk
- 11. 單擊其他圖像顯示圖像幾秒鐘
- 12. 在ios 3秒鐘登錄後顯示加載視圖
- 13. 如何在Android中顯示數據庫中的圖像和描述
- 14. 如何顯示一個圖像五秒鐘然後顯示另一個(Android Studio)
- 15. 如何讓文本塊顯示5秒鐘?
- 16. 如何顯示jmx MBean的類描述,屬性描述和操作描述
- 17. 如何顯示用戶在Django模板中寫入的圖像描述
- 18. Eclipse顯示視圖嚮導顯示使用f2顯示描述...但在哪裏設置視圖的描述
- 19. SQL:在文本中顯示描述而不是位值
- 20. 描述()在CakePHP中3.X
- 21. WordPress:爲非圖像媒體顯示標題或描述,如PDF
- 22. 描述文本在文本字段中?
- 23. 如何暫停顯示器幾秒鐘?
- 24. 如何顯示類別描述?
- 25. 如何顯示Woocommerce類別描述
- 26. 如何在VBScript中顯示幾秒鐘的提示信息?
- 27. 在Android中顯示ProgressBar幾秒鐘
- 28. 如何在RSpec中未描述的示例上顯示失敗?
- 29. 我如何描述AMI圖像?
- 30. 如何顯示在天毫秒爲單位:小時:分鐘:秒
通常你會得到幫助這裏固定的東西你不工作。你嘗試過什麼? – 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