Question: I have a function that if i pass a source of image to it, it should modify the src attribute of $("#image") element, this function is called when i click a button which isn't inside a form (this means that page is not reloaded)

```
function modify_image(image_src){
   $("#image").attr("src", image_src);
}

```

how i can get the width of this image after his **src** changed ?

Answer: 
The load event will fire when the image has updated:

```
$("#image").attr("src", image_src)
    .load(function () {
      $(this).width(); // the new image width
    })

```
Here's my flavour:

```
    function modify_image(image_src){
       $("#image").attr("src", image_src).load(function () {
            console.log($(this).width());
        });
    }

```