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