當我在下面的代碼中應用的Javascript它只第一圖像產生的效果只有第一個圖像尺寸改變,甚至我的鼠標懸停在任何圖像如何在鼠標懸停在循環期間更改圖像大小?
<div class="container">
<div class="row">
@foreach($gigs as $gig)
<div class=" col-lg-3 col-md-3 col-sm-6 col-xs-12 gigbox">
<div class="panel panel-default" style="height: 285px">
<img src="{{URL::asset($gig->image)}}" id="img" width="100%" onmouseover="changesize()" height="160" alt="">
<ul class="skillUl">
<li class="gigtitle" style="list-style: none"><a href="{{route('gig',['gig_id'=>$gig->id, 'gig_title'=>$gig->gigtitle])}}"> I will {{$gig->gigtitle}}</a></li>
<a class="startingFrom" href="{{route('gig',['gig_id'=>$gig->id, 'gig_title'=>$gig->gigtitle])}}">Starting From <Span class="price"> Rs {{$gig->price}}</Span></a>
</ul>
</div>
</div>
@endforeach
</div>
</div>
JavaScript代碼是在這裏
<script>
function changesize() {
document.getElementById("img").style.width = "130px";
}
</script>
一個ID必須是唯一的... 使用類或使用CSS設置img:hover ...變換比例尺 –
你能爲我寫代碼嗎?我在網上新 –
把css樣本放在你的CSS結尾... –