将全局JavaScript数组值传递给HTML标记 [英] Pass a global javascript array value into a HTML Tag
本文介绍了将全局JavaScript数组值传递给HTML标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上想知道我是否可以将全局javascript数组值传递给html标签,特别是在img(title)标签内?可以这样做:
< img src =_ info.gifheight =26width =37title = myArray的[5] />
如果是这样,如果没有,人们可能会提供其他建议。
谢谢
解决方案
我会这样做:
< img id =image-1src =_ info.gifheight =26width =37/>
< script type =text / javascript>
var image = document.getElementById('image-1');
image.setAttribute('title',myArray [5]);
< / script>
Just wondering if it's possible to pass a global javascript array value into a html tag, specifically inside a img (title) tag?
Basically want to know if I can do this:
<img src="_info.gif" height="26" width="37" title=myArray[5]/>
If so, how and if not, can people possibly provide other suggestions.
Thanks
解决方案
I would do it this way:
<img id="image-1" src="_info.gif" height="26" width="37" />
<script type="text/javascript">
var image = document.getElementById('image-1');
image.setAttribute('title', myArray[5]);
</script>
这篇关于将全局JavaScript数组值传递给HTML标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文