下面的js代码怎么改成jq,求解答!!!
就是希望将class="divOne"的<a>标签的宽和高一样,网上很多例子,但是浏览器一缩小,宽高就不一样了。想实现正方形效果,纠结了好久!!求解答!!!!js代码:<...
就是希望将class="divOne"的<a>标签的宽和高一样,网上很多例子,但是浏览器一缩小,宽高就不一样了。想实现正方形效果,纠结了好久!!求解答!!!!
js代码:
<script>
window.onload=window.onresize=function(){
var divOne=document.getElementById('divOne');
divOne.style.height=divOne.offsetWidth+'px';
}
</script>
html部分:
<div class="pro-all">
<ul>
<li>
<a href="#" class="divOne" id="divOne">
<img src="../images/index-cen1.png">
<div class="info">
<span>¥99</span>
<strong>小天使蛋糕</strong>
</div>
</a>
</li>
</ul>
</div> 展开
js代码:
<script>
window.onload=window.onresize=function(){
var divOne=document.getElementById('divOne');
divOne.style.height=divOne.offsetWidth+'px';
}
</script>
html部分:
<div class="pro-all">
<ul>
<li>
<a href="#" class="divOne" id="divOne">
<img src="../images/index-cen1.png">
<div class="info">
<span>¥99</span>
<strong>小天使蛋糕</strong>
</div>
</a>
</li>
</ul>
</div> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询