Adding class to clicked element
问题 I'm trying to add a class to a clicked element. There are multiple elements with unique IDs so I "don't know" what the ID of the element is. Can I use a modified version of the below code to achieve this? Jquery: $(document).ready(function () { $(this).on('click', function () { $(this).addClass('widget-selected'); }); }); EDIT: A markup can be like this: <h1 id="textHolder1" contenteditable="true">Text to edit</h1> 回答1: I would try with this.. $(document).ready(function () { //this will