これまでの私のコード:
$(".lorem img:not(.full-img)").each(function() {
$(this).addClass("inline-img");
var imgWidth = $(this).prop('width');
var imgHeight = $(this).prop('height');
var imgFloat = $(this).prop('float');
$(this).wrap('<div class="inline-img-wrap" />');
if ($(this).prop("title")!='') {
$('<p class="inline-img-caption">').text($(this).prop('title')).insertAfter($(this));
}
});
テキストの本文内で画像を検索し、そのtitle
値をキャプションとして下に追加し、との両方img
をp
でラップしていdiv.inline-img-wrap
ます。それはうまくいきます。
私が助けを必要としているのは、img
代わりに新しいラッピングdivにのスタイルを適用することです。これだけの変数を作成したことがわかりますが、それらを機能に適用することはできません。$this
常に画像に適用され、<div class="inline-img-wrap" style="width:'+imgWidth+'">
機能しません。
すべてのアドバイスに感謝します!