Search code examples
jqueryresizeresizable

Jquery.ui : Get id from current element


How do I get the id of current element while I'm resizing? the following I made does not work, thank you

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(document).ready(
function(){
    $( ".resizable" ).resizable({
        resize: function( event, ui ) {alert(ui.element.id)}
    })
}
);
</script>

<img class="resizable" id="25" src="test1.jpg">
<img class="resizable" id="26" src="test2.jpg">
<img class="resizable" id="27" src="test3.jpg">

Solution

  • try this

    $( ".resizable" ).resizable({
        resize: function( event, ui ) {
                alert($(ui.element).children('img').attr('id'));
        }
    });