It depends on the element type and parents, children anything that can lead you to that element let's say that the element is an anchor so you make it like this
$(document).ready(function () {
$('a').on('click', function () {
$(this).addClass('widget-selected');
});
});
Or all the elements are childs of parent class parent
$(document).ready(function () {
$('.parent a').on('click', function () {
$(this).addClass('widget-selected');
});
});
There are a lot of ways to achieve this
If you posted HTML code it will help very much
If you are generating the ID's dynamically you can make a string of them like the following
var str = "#firstID,#secondID,#third,#fourth";
and use it like this
$(document).ready(function () {
$(str).on('click', function () {
$(this).addClass('widget-selected');
});
});
I hope this can lead you to your goal
EDIT
after you added the HTML you should take a look at the following
http://api.jquery.com/attribute-starts-with-selector/
OR you can select using contenteditable=true
Some of the folks here added an answer about the starts with attribute
h1
elements ? – Shaff$('.clickable').on...
– Markup