I have 2 spans
<span contentEditable=true class="editspan"></span>
<span class="pencilspan glyphicon glyphicon-pencil pull-right"></span>
and a js function
$(document).on('click', '.pencilspan', function () {
console.log("clicked pencil");
});
What I want is when I click on pencilspan the contentEditable area of editspan should get highlighted(input box should be visible). How can I achieve this?
You should try focus() method :
$(document).on('click', '.pencilspan', function () {
$(this).siblings('.editspan').focus();
});
For empty span issue you can follow this link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With