4
4
4eloBek2015-08-21 21:53:59
JavaScript
4eloBek, 2015-08-21 21:53:59

How to call a function using different events on bold text?

For example, when clicking on bold text (i.e., one that is framed by <b></b>tags), this works:

$('#content').on('click', 'b', function() {  alert("Вы кликнули на жирном тексте")  });


With the rest of the events that I need - select, keydown - this does not roll (
Please tell me what is wrong)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mak Alexey, 2015-08-21
@S-ed

The select event is sent to an element when the user makes a text selection inside it. This event is limited to <input type="text">fields and <textarea>boxes.

So the problem is that the event is not generated in principle and there is nothing you can do about it.

A
Alexey, 2015-08-21
@dzheka3d

$('#content b').live('click', function() { alert("You clicked on bold text") });

S
Sergey Sokolov, 2015-08-21
@sergiks

Interest Ask. Not a complete solution, but it will help to find: Fiddle , where they determine the position of the cursor in an editable element with html tags.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question