特定の画像を親の幅に自動的にサイズ変更するjQuery関数を作成しようとしています。関連する場合、これは vbulletin 4.2.0 用です
関連する(簡略化された)コードは次のとおりです。
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var newWidth = $('.floatcontainer.doc_header').css("width");
$('.logo-image').css("width", newWidth);
});
</script>
</head>
<div class="floatcontainer.doc_header" style="width: 90%; height: 200px;">
<img class=".logo-image" src="/img/headerimg.jpg"/> //the image is naturally 1092x200
</div>
解決しました!この画像の css を編集する場所がようやくわかったので、jQuery で編集する必要はありませんでした。まさに私が探していた解決策ではありませんが、ちょっと - 誰が不平を言っているのですか!
ご協力いただきありがとうございます!