Thursday, October 2, 2008

[jQuery] Re: if ($(event.target).is('a.edit')) with img

Why don't use the simple click function?

$('a.edit-building').click(function(){
    //do stuff
     return false;
});

On Thu, Oct 2, 2008 at 14:43, light-blue <Sean.Wingert@gmail.com> wrote:

Hopefully simple problem. I click an img link, html like this

<a class="edit-building" href="/edit-building/145">
<img src="icons/edit.png"/>
</a>

jquery like this

if ($(event.target).is('a.edit-building')) {
 var building = function (data) {
 ..do stuff
 }
 $.get(event.target, null, building);
 return false;
}

but the binding doesn't work, probably because the target is my img
not my link. How can I click the image and fire the code for my a.edit-
building?

Thanks!


No comments: