s Gets the image address in the UEditor text editor

JS gets the image address in the UEditor text editor

I found many methods on the Internet before writing. The simplest idea should be 1. Get the content in UEditor; 2. Convert the obtained string into a jquery object; 3. The selector finds the img element and gets the src value.


var content= UE.getEditor('details').getContent();//获取编辑器内容
var $div = document.createElement("div");//创建一个div元素对象
$div.innerHTML = content;//往div里填充html
var $v = $($div);//从dom对象转换成jquery对象
$.each($v.find("img"),function (v,i) {//选择器找到img元素,循环获取src值
console.log("src======"+i.src);
});

Insert image description here

Guess you like

Origin blog.csdn.net/m0_73358221/article/details/129875133