我正在尝试创建一个弹出窗口,根据类别弹出相应的模态。弹出窗口有一个动态类。所以,如果我有一个叫做的课程 popup_1然后它应该显示popup_modal_1
@foreach($single_portfolio->portfolio as $portfolio)
<h2>{!! $portfolio->title !!}</h2>
<?php
$thumb = $portfolio->image;
?>
<div class="popup popup_{!! $portfolio->id !!}">
<img src="{!! asset("portfolio_images/thumbs/$thumb") !!}">
</div>
<div id="myModal" class="popup_modal popup_modal_{!! $portfolio->id !!}">
<div class="modal-content">
<span class="close">
×
</span>
<div class="portfolio_popup">
<div class="portfolio_wrapper">
<?php
$fullImage = $portfolio->image2;
$fullImg = $portfolio->image2;
?>
<div>
<img src="{!! asset("portfolio_images/$img") !!}">
</div>
</div>
<div class="portfolio_nav">
<div>
<img src="{!! asset("portfolio_images/$thumbImg") !!}">
</div>
</div>
</div>
</div>
</div>
@endforeach
我的JS
$('.popup').click(function(){
$('.popup_modal').show();
});
答案 0 :(得分:1)
您可以尝试:
$('.popup').click(function(){
$(this).next('.popup_modal').show(); //assuming that associated popup_modal will be immediate to your popup link
});