I want a click event to fire on any element with class ‘editable’ that has, or can have (or traditionally has) text content: a, li, h1, h2, h3, p.. but not video, img and other elements that don’t directly contain text.
Is there a way to do this without referring to specific html elements? or.. how would I exclude specific element types from the following:
$(".editable").click(function(event) {
alert("edit text!");
});
I doubt if there is a pre-defined selector that will choose only these elements.
as for execlusion you can use the not() function:
Here’s the documentation:
http://api.jquery.com/not/
EDIT: it’ll probably be more efficient to call the function once thus: