Reputation: 203
While resizing the picture, I want the picture width added to < div id="w" >< /div >, I have tried the following, anyone can help? thank you:
<script>
$(document).ready(
function() {
$( "#resizable" ).resizable({
resize: select_function
});
});
var select_function = function(event, ui)
{
$("#w").text($( "#resizable" ).attr("width"));
};
</script>
<div id="w">Test</div>
<img border="0" id="resizable" src="picture.png">
Upvotes: 0
Views: 64
Reputation: 2520
Have you tried getting the width of the image like this?
$("#w").html($( "#resizable" ).width());
Upvotes: 1
Reputation: 21091
You either need to add a width
attribute to the img
tag.
<img border="0" id="resizable" src="picture.png" width="500px">
Or you need to use the built-in JQuery width()
function.
$( "#resizable" ).width();
I recommend checking out the JQuery docs on .width() and .attr() to get a better understanding.
Upvotes: 0
Reputation: 887797
You don't have a width=""
attribute.
To get the actual width of the element, call $( "#resizable" ).width()
.
Upvotes: 1