我想从模板中获取每个项目。该模板的样子:从句柄模板获取每个元素与jQuery
<div class="row flush" id="photos_list">
<script id="photo_list_template" type="text/x-handlebars-template">
{{#each this}}
<div class="3u photo">
<img src="{{url}}" alt="{{name}}"/>
</div>
{{/each}}
</script>
</div>
,现在我想利用各张图片,并在悬停显示ALT,和黑色背景,但我似乎无法使它工作,采取的元素。 我想是这样的:
$('div.row').find('img').hover(function(){
//some code
})
这是生成的html:
<div class="row flush" id="photos_list">
<div class="3u photo">
<img src="http://everythingawesomeever.files.wordpress.com/2013/07/awesome-meter.jpg" alt="Again, with the insanity.">
</div>
<div class="3u photo">
<img src="http://who-is-awesome.com/who-is-awesome.jpg" alt="Who's awesome?">
</div>
<div class="3u photo">
<img src="http://www.miataturbo.net/attachments/insert-bs-here-4/78009-my-little-random-picture-thread-*sfw-huffy-*-1682345-slide-slide-1-biz-stone-explains-how-he-turned-91-random-photos-into-movie-jpg?datelin" alt="After Mask">
</div>
<div class="3u photo">
<img src="http://www.miataturbo.net/attachments/insert-bs-here-4/76756-my-little-random-picture-thread-*sfw-huffy-*-11254201pkm5958-jpg?dateline=1368653578" alt="English Muffin">
</div>
</div>
我该怎么办呢?
似乎是正确的,你的后生成的html ..也许有一些problmes ...还悬停需要2个功能(){}两个状态... – reyaner