创建img标签
$(function(){
evalStr()
}
function evalStr() {
var photo = $("#potho").val();//photo是一个json类型的字符串
if (photo == null) {
return
}
var photourl = eval(photo);
$("#imgId12").empty();
for(var i in photourl){
var img = document.createElement("img");
//设置 img 属性,如 id
img.setAttribute("style", "height: 200px;width: 200px");
//设置 img 图片地址
img.src = photourl[i].fileUrl;
document.getElementById("imgId12").appendChild(img)
}
}
创建a标签
function evalStr(url) {
var a1=document.createElement('a');//创建a标签
var text=document.createTextNode('a标签显示的名字');//设置a标签的text
a1.appendChild(text);
a1.setAttribute('href',url)
$("#divId").appendChild(a1);
}