I
I
i_want_to_know_everything2015-10-21 03:40:41
JavaScript
i_want_to_know_everything, 2015-10-21 03:40:41

Getting full paragraph into selected text?

Current state jsfiddle.net/dan2b5o2/2
How, if not a full paragraph/paragraphs are selected, how to drag the text of a full paragraph into the $txt variable with the closing and opening tags inclusive.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2015-10-21
@i_want_to_know_everything

If I understand correctly, then you can do something like this:
1 remember the clicked element
2 .closest('p') and .html()
demo: jsfiddle.net/dan2b5o2/5

I
i_want_to_know_everything, 2015-10-21
@i_want_to_know_everything

I did it like this, jsfiddle.net/dan2b5o2/3 but it's not very clear how to check for parentNode.name
in order to exclude the choice of tags inside the paragraph, such a construction console.log(container.parentElement.nodeName);in IE gives an error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question