![](/img/trans.png)
[英]How can I get the text that is going to be pasted in my html text editor?
[英]From html code I want the actual image to be pasted in text editor
我有一個圖像的html代碼,我希望將實際圖像粘貼到文本編輯器中,從剪貼板粘貼,是否可以使用jquery和javascript。
你有嘗試過嗎?
$(element).append('<img id="imgID" src="imgName.jpg" />')
要么
$(element).prepend('<img id="imgID" src="imgName.jpg" />')
類似於/<img(?:.*)src=(?:"|')([^"']+)(?:"|')/i.exec('<img id="imgID" src="imgName.jpg" />')[1]
應該這樣做。
或者,如果您已經有了jQuery $('<img id="imgID" src="imgName.jpg" />').attr('src')
應該可以
如果要說的是要能夠將圖像粘貼到Web應用程序的文本編輯器中,建議您查看一個富文本編輯器庫,例如CKEditor 。 這樣可以輕松粘貼圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.