JQuery 获取所有;来自 的标签并在- 中显示它们
- 中显示它们
这是我的 html(即时通讯使用 Galleria Image Gallery - 基于 JQuery)
<div id="galleria">
<img alt="Productname 1" src="bens_img/1.jpg">
<img alt="Productname 2" src="bens_img/2.jpg">
<img alt="Productname 3" src="bens_img/3.jpg">
<img alt="Guess what?" src="bens_img/4.jpg">
</div>
伪代码
Get string from <alt> from <img>
Create a new <li> and paste the <alt> string from <img> in it
这应该使用所有(即:四个)img alt 字符串来完成。它应该看起来像这样:
<ul class="textformat">
<li>Productname 1</li>
<li>Productname 2</li>
<li>Productname 3</li>
<li>Guess what?</li>
</ul> <!-- yeah this was all done by java-script -->
This is my html (im using Galleria Image Gallery - JQuery Based)
<div id="galleria">
<img alt="Productname 1" src="bens_img/1.jpg">
<img alt="Productname 2" src="bens_img/2.jpg">
<img alt="Productname 3" src="bens_img/3.jpg">
<img alt="Guess what?" src="bens_img/4.jpg">
</div>
Pseudo Code
Get string from <alt> from <img>
Create a new <li> and paste the <alt> string from <img> in it
This should be done with all (ie: four) img alt strings. It should look like this:
<ul class="textformat">
<li>Productname 1</li>
<li>Productname 2</li>
<li>Productname 3</li>
<li>Guess what?</li>
</ul> <!-- yeah this was all done by java-script -->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
就像这样:
Like so:
对于标记每个具有“alt”的图像
for tag every image that has 'alt'
您需要
.attr
jQuery 选择器:或者您可以使用
$('#galleria').find('img')
或$('#galleria' ).children('img')
You need the
.attr
jQuery selector:Or you can use
$('#galleria').find('img')
or$('#galleria').children('img')
尝试使用 jQuery 的
map()
函数:Try using jQuery's
map()
function:您可以扩展 Galleria 以将 alt 标签或描述放在另一个 div 中,不知道如何将其放入 li 中,我猜是一些 jQuery
<代码>
扩展:函数(){
this.bind(Galleria.IMAGE, 函数(e) {
$('.caption').html(this.$('信息描述').html());
})
}
You can extend galleria to put the alt tags or descriptions in another div, not sure how to put it into an li, some jQuery i guess
extend: function() {
this.bind(Galleria.IMAGE, function(e) {
$('.caption').html(this.$('info-description').html());
})
}