![](/img/trans.png)
[英]How to get the value of input tag inside the clicked div using Jquery?
[英]How to get the value from css of “div” tag using jQuery?
例如:
<div id="h" style="background-image:url('images//line.jpg'); background-repeat: repeat-x; width:300px; height:25px; padding-left:10px; color:white;">Frame</div>
現在,我想使用jQuery從style中獲取width的值。 jQuery應該是什么。
$('#h').width() // from jQuery dimensions (core)
要么
$('#h').css('width');
.width()
返回計算出的寬度。 .css('width')
只會返回您已寫入樣式的內容。 因此,通常來說,最好使用.width()
除非您真的想知道實際值。
如果您需要元素的寬度更“詳細”,請從jQuery尺寸中.innerWidth()
和.outerWidth()
方法。 這些使用padding
, borders
, padding
等計算寬度。
css方法:
var width = $('#h').css('width');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.