views:

24

answers:

2

Hi ,

I have an image on which "click to edit" is written now when i click that part i want to show edit box where "Type 1" is written.

I have tried to put edit box but unable to get the click event ...

here is the image

http://www.freeimagehosting.net/image.php?55dd1b316d.png

+1  A: 

i assume you're using jquery

$('#yourimageid').bind('click', function(){
    .... your box appearance code here
});

if not it's a bit mor letters, but the same thing

document.getElementById('yourimageid').onclick = function(){
     .... your box appearance code here
}
helle
Actually, they're not *exactly* the same thing. The former you can run multiple times and it will execute all of the callbacks. The latter will only execute the last one assigned.
icktoofay
@icktoofay thanks for the addendum. this is for sure neccessary to mention!
helle
but this code will execute when ever i will click on any part of image i just want to fire click event while user click on "click to edit..." text inside image
Hunt
okay then i suggest using image-maps ... and binding the event on that area then.
helle
@Hunt If you want to have more than one link per image (or a restricted clickable area), it's the same principle. You'd need to create an image map. You'd then give each image-map link a separate ID and use helle's method.
Brock Adams
A: 
$("#the-image").click(function() {
    // show the edit box
    $("#edit-box").show();
}

If it's something simple like that, then just position #edit-box with CSS.

N. Lucas