Reputation: 6584
I'm stuck with a concept, not sure if my logic is right, it most likely isn't.
I'm hoping to achieve a div
delete. So I click the div
and it makes it the active div
and then I can delete it with the backspace key.
So the flow is -. Click Element - Hit Backspace - $(this).remove();
,
but not sure how to target the element with a click. I had:
$(".spike").live(event, function(del) {
if (del.keyCode == 8) { $(this).remove();}
});
but it doesn't work. (The event is bound to click and ipad touch).
Basically is there any way I can use the click event to target a div
, maybe to a global variable, that then allows me perform actions to it?
Upvotes: 0
Views: 792
Reputation: 78590
Hm... I have little to offer but a demo http://jsfiddle.net/E8RaX/1
but the idea is that you assign a class to the active object and then with some prevent defaults you remove any divs with that class.
Upvotes: 0
Reputation: 8700
Well the idea is to select an item, and save the selection. Then if the key you want is pressed, delete that item.
Look at this example: http://jsfiddle.net/GVgEy/5/
Upvotes: 1
Reputation: 26554
change "event" for "click" which is the event you want to handle.
$(".spike").live("click", function(del) {
if (del.keyCode == 8) { $(this).remove();}
});
Upvotes: 0