如何为具有相同ID的多个自动生成按钮提供相同的链接?
我试过了,但它只给出第一个按钮链接,其余的按钮保持为空
$('#Button').click(function() {
window.location='aaa.html';
});
Run Code Online (Sandbox Code Playgroud) 我有这样的HTML模板:
<div class="row flush" id="photos_list">
<script id="photo_list_template" type="text/x-handlebars-template">
{{#each this}}
<div class="3u photo">
<div class="imageover">
<h1></h1>
</div>
<img src="{{url}}" alt="{{title}}" name="{{model}}"/>
</div>
{{/each}}
</script>
</div>
Run Code Online (Sandbox Code Playgroud)
当我将鼠标悬停在一张图像上时,我想要隐藏它并显示imageoverdiv.到目前为止我有这个jQuery,但我不明白我做错了什么:
$('#work-wrapper2 div.row').on('mouseenter mouseleave', 'img', function(e) {
var $title = $(this).attr('alt');
var $model = $(this).attr('name');
var $url = $(this).attr('src');
if (e.type == 'mouseenter') {
$('img', this).hide();
} else {}
});
Run Code Online (Sandbox Code Playgroud) 我有一个图像列表,我想在点击其中一个图像时更改div的背景.我有这样的东西,但它不起作用:
jQuery:
$('.container-inner').find('img').click(function(){
var $url = $(this).attr('src');
console.log($url);
$('.container-outer').css({'background-image': $url});
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="container-outer">
<div class="container-inner">
<a href="#"><img src="http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg"></a>
<a href="#"><img src="http://a.tgcdn.net/images/products/additional/large/e718_broke_something.jpg"/></a>
<a href="#"><img src="http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg"></a>
<a href="#"><img src="http://inspiretrends.com/wp-content/uploads/2013/07/InteractiveSVG.jpg"/></a>
<a href="#"><img src="http://images5.fanpop.com/image/photos/30800000/-Random-random-30843841-1920-1080.jpg"/></a>
<a href="#"><img src="http://inspiretrends.com/wp-content/uploads/2013/07/InteractiveSVG.jpg"/></a>
<a href="#"><img src="http://inspiretrends.com/wp-content/uploads/2013/07/InteractiveSVG.jpg"/></a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?