sha*_*fty 1 jquery attributes attr
我发现jquery attr()方法不喜欢接受带有"px"的值.生成的图像最终为零宽度和高度!这是一个错误,一个疏忽或一些功能?
这很容易解决,但我真的不喜欢没有单位设置值.它可能导致不可预测的行为.
在firefox 3.6和opera 11中测试了以下内容:
<html>
<head>
<script type="text/javascript" src="../jquery-1.4.min.js"></script>
<script type="text/javascript" src="return.js"></script>
</head>
<body>
<div id="links" style="width:500px; background:#000;">
<img src="images/ref.png" width="500px" height="500px" alt="reference" />
</div>
</body>
</html>
$(document).ready(function(){
$('div#links').css({ 'height':"300px" });
$('div#links img').attr({ 'width':"100px", 'height':"100px" }); // This doesn't work!
//$('div#links img').attr({ 'width':"100", 'height':"100" }); // This works.
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
208 次 |
| 最近记录: |