I am using the following code to highlighting the element :
$(".ss").live({
mouseenter: function () { HighLight(this) },
mouseleave: function () { OffLight(this); },
keypress: function () { KeyOperation(this); }
});
function HightLight(s)
{
$(s).css({border : "1px solid red"});
}
function OffLight(s)
{
$(s).css({border : "0"});
}
function KeyOperation(s)
{
$(s).remove();
}
KeyOperation() function is not executing on keypress.
Here i am trying to do that when user highlight any element, and while highlighting, if he press Delete key , than that element should be deleted.But this is not working, can anybody tell me how can i do this?
I believe this is what you’re after. Hovering over any
.sselement will add a temporary class. If the user presses key 46 at any time, items with that class will be removed. See working fiddle below.It should be clear from this example that
$.liveis no longer encouraged for event delegation. From here on use$.oninstead.Fiddle: http://jsfiddle.net/YS7jH/2/