1

I'm using Firefox.

I want to make an image inside a contenteditable div get selected by code like when you click the image. Bear in mind that when you click on image inside a contenteditable div the image get some little squares around (eight in total) which you can use to resize the image.

you can test the following jsfiddle (please click the image to see the little squares):

http://jsfiddle.net/gxux65v7/

HTML:

<input type="button" id="button_select" value="Select" /><br /><br />
<div contenteditable="true">
    <img id="image_plane" src="http://i2.cdn.turner.com/cnn/dam/assets/130731134001-planes-film-dusty-story-top.jpg" width="300" />
</div>

JAVASCRIPT:

$(function(){
    $("#button_select").click(function(){
        /*
         ¿what code to put here to make the image selected and the
         little squares around the image appears as occur when you
         click on the image?
         */
        // $("#image_plane").select(); // this doesn't work
    });
});

Thank you!

nightclub
  • 671
  • 2
  • 9
  • 20
  • So if I get you right you want to click on the select button which selects the image? – VRC Sep 16 '14 at 14:09
  • I want to put some code inside the button handler, in order that when you click the button, the image get selected with the little squares around (the same squares that appears when you click the image) – nightclub Sep 16 '14 at 14:17
  • jqueryui has a resizable() – artm Sep 16 '14 at 14:23
  • but I need the little squares get shown as occur when you click the image – nightclub Sep 16 '14 at 14:24
  • I dont think its possible to do what you want. Maybe you can describe your scenario so there might be another solution for achiving your goal. – VRC Sep 16 '14 at 15:51
  • Another solution for me would be, once the image is selected with the little squares around, find some way by code to remove those little squares. – nightclub Sep 16 '14 at 17:00

0 Answers0