JQUERY, Extract only the first paragraph

Given the block of text in the CKEDITOR editor with the paragraphs contained in the PARAGRAPH tags, how can I do in JQUERY to extract only the first paragraph

Example:

blah blah blah blah blah

blah blah blah 123123blah blah

blah blah blah blah b1212lah

blah blah blah blaasdasdadsh blah

Only:

blah blah blah blah blah

thank

+3
source share
4 answers

You can use: first selector:

$('p:first');
+6
source

Since CKeditor is in an iframe, you may need something line by line:

$("#cke_contents_editor1 iframe").contents().find('p:first').text()

to extract the text.

+2
source

, CKEditor - , jQuery :

$("p:first").text();

Get the text in the first element <p>. If the paragraphs are wrapped <div>or with another element with a specific identifier, you can do:

$("#id-of-div p:first").text();
0
source

Source: https://habr.com/ru/post/1727561/


All Articles