Given a block of text in a TEXT EDITOR (CKEDITOR), with paragraphs contained in 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
To Just:
blah blah bla开发者_C百科h blah blah
Thanks
You can use the :first selector:
$('p:first');
Since CKeditor is in an iframe, you might need something along the lines of:
$("#cke_contents_editor1 iframe").contents().find('p:first').text()
to extract the text.
http://api.jquery.com/first/
I don't know if CKEditor would affect this in any way, but with jQuery you should be able to use:
$("p:first").text();
To get the text in the first <p>
element. If the paragraphs are wrapped by a <div>
or another element with a specific ID, you can do:
$("#id-of-div p:first").text();
精彩评论