Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 ckeditor,下面是我用于 ckeditor 的 textarea 和它的内容,我怎样才能只在<p id="footer"></p>使用 jquery的内部获取内容
<p id="footer"></p>
<textarea id="cheditor_text" name="cheditor_text" rows="10"> <p> welcome to our company </p> <p id="footer"> Copy right @ exak=mple.com </p> </textarea>
阅读此链接,它很有帮助。
尝试使用getData();
有用的链接
你可以这样做,
现场演示
txt = $('#cheditor_text').text(); html = $('<div>').append(txt).find('#footer').prev()[0].outerHTML;
不使用 outHTML
txt = $('#cheditor_text').text(); pTag = $('<div>').append(txt).find('#footer').prev(); alert($('<div>').append(pTag).html())
尝试
var value = CKEDITOR.instances['cheditor_text'].getData(); $(value).find('#footer').html();
或者
$('#cheditor_text').ckeditor(function( textarea ){ $($(textarea).val()).find('#footer').html(); });