私は画像draggable
を持っていて、PHPで保存したいので、内部のスタイルを取得して入力フィールドに値として入れましたので、$_POST
で取得できますそれは私がinnerHTML
構文を呼び出しを通じてそれを得る可能性があり、内側HTML
データだろうが、そうのようにそこには、画像のスタイルを取得する任意の方法JavaScriptを使ってCSSスタイルのプロパティを取得する
<div class="scott_img">
<img id="uploadPreview" src="<?php echo (empty($data['profile_pic'])) ? "images/profile.jpg" : "uploads/" . $data['profile_pic']; ?>" style="style goes here">
<span class="scouttag"></span>
</div>
<form method="POST" action="profile.php?uid=<?php echo $uid; ?>" enctype="multipart/form-data" style="text-align:center;">
<input id="uploadImage" type="file" name="image" style="margin:auto;" />
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
<input type="hidden" id="uploadPreview1" value="need style here so i can save it to database" />
<button type="submit" name="update_picture" class="btn_form">Update Picture</button>
</form>
<img class="scott_line"src="images/line.png">
<script>
(function() {
var elem = document.getElementById('uploadPreview');
var val = getComputedStyle(elem);
document.getElementById('uploadPreview1').value = val;
var $section = $('.scott_img').first();
$section.find('#uploadPreview').panzoom({
$zoomRange: $section.find(".zoom-range"),
$reset: $section.find(".reset")
});
})();
</script>
があるため
'getComputedStyle(elem)'は何を返しますか? –
値= "[オブジェクトCSSStyleDeclaration]" –