setAttribute 添加属性js_jq

属性
js setAttribute
document.getElementsByName("test")[0].setAttribute("src", "../img/jia.png");


jquery attr
$("#id").attr("src", "../img/jia.png");

 

 

var po = {};
po.zt = 0;
po.sj = "00:22";
po.name = "赵家湖";
po.phone = "13500000958";
po.qxd = "石井山抢修队001";
var popu = initwgdsjDiv(po);

 

function  abc(a) {

debugger
  console.log(a.getAttribute('mapphone'));
}

 

 

//弹窗例子,未派单的工单弹窗写死的
function initwgdsjDiv(map) {

var list = document.createElement('div');
list.style.cssText = "width: 220px;height:154px;border-radius:10px;box-shadow:0px 10px 15px rgba(214,214,214,0.5);";

var div1 = document.createElement('div');
div1.style.cssText = " height: 33px; position: relative; top: -25px; padding-left: 21px;";

var img1 = document.createElement('img');

var div2 = document.createElement('div');
div2.style.cssText = "width: 100px; height: 20px; text-align: center; float: left;";
var img2 = document.createElement('img');
img2.src = "./img/6.png";
div2.appendChild(img2);

var div3 = document.createElement('div');
div3.style.cssText = "width: 110px; height: 20px; text-align: center; float: right;";
var img3 = document.createElement('img');
img3.src = "./img/7.png";
div3.appendChild(img3);

var div4 = document.createElement('div');
div4.style.cssText = "width: 100px; height: 35px; text-align: center; float: left; font-size: 21px;font-family: -webkit-pictograph;font-weight: bold;line-height: 35px;font-size:24px;font-family:Arial;font-weight:bold;line-height:28px;color:rgba(60,60,60,1);";
div4.id = "SJ";
div4.innerText = map.sj;

var div5 = document.createElement('div');
div5.style.cssText = "width: 110px; height: 38px; float: right;";

var div51 = document.createElement('div');
div51.style.cssText = "font-weight: 600; height: 20px; text-align: center;font-size:18px;font-family:PingFang SC;";
div51.id = "WXRY";
div51.innerText = map.name;
var div52 = document.createElement('div');//手机号码
div52.style.cssText = "width: 100px; height: 22px; text-align: center; font-size: 12px;color: rgba(39, 39, 39, 0.57);font-weight:400;font-family:Arial; padding-top:5px;line-height:17px;";
div52.id = "LXDH";
div52.innerText = map.phone;
div5.appendChild(div51);
div5.appendChild(div52);

var div6 = document.createElement('div');
div6.style.cssText = "padding-top: 5px;width: 100px; float: left; text-align: center; font-size: 12px;font-family:PingFang SC;font-weight:400;padding-top: 2px;";
div6.innerText = "派单倒计时";
img1.src = "./img/15.png";
div1.appendChild(img1);

var div7 = document.createElement('div');
div7.style.cssText = "width: 110px; float: right; font-size: 12px;font-family:PingFang SC;font-weight:400;line-height:17px;padding-top:2px;";
div7.id = "QXD";
div7.innerText = map.qxd;

//按钮
var values = '派单';
var idflag = 'idflag';
var div8 = document.createElement('div');
div8.style.cssText = "width:30%;float: left;display;inline-block;padding-top:8px;margin-left:12px;";//按钮位置
var button1 = document.createElement("input");
button1.setAttribute("type", "button");
button1.setAttribute("value", values);
button1.setAttribute("id", idflag);
// button.setAttribute("class", class);
button1.setAttribute("class", 'butclass');
button1.style.cssText = "background: rgba(85, 201, 194, 1);color: rgba(255, 255, 255, 1);";//按钮中字体
button1.setAttribute("mapPhone", map.phone);
  button1.setAttribute("onclick", 'abc(this)');
    button1.setAttribute("onclick", 'abc('+map+')');
div8.appendChild(button1);

var div9 = document.createElement('div');
div9.style.cssText = "width:30%;display:inline-block;display;inline-block;padding-top:4px;";
var button2 = document.createElement("input");
button2.setAttribute("type", "button");
button2.setAttribute("value", '工单处理');
button2.setAttribute("id", idflag);
// button.setAttribute("class", class);
button2.setAttribute("class", 'butclass butfont');
button2.setAttribute("onclick", "function(this.id)");
div9.appendChild(button2);

var div10 = document.createElement('div');
div10.style.cssText = "width:30%;display:inline-block;display;inline-block;padding-top:4px;";
var button3 = document.createElement("input");
button3.setAttribute("type", "button");
button3.setAttribute("value", '审核');
button3.setAttribute("id", idflag);
// button.setAttribute("class", class);
button3.setAttribute("class", 'butclass butfont');
button3.setAttribute("onclick", "function(this.id)");
div10.appendChild(button3);

// var button = "<a role='button' id="+jinfo[i].id+" onclick='function(this.id)'><i class='icon-edit'></i></a>";
// div8.innerHTML += button;

list.appendChild(div1);
list.appendChild(div2);
list.appendChild(div3);
list.appendChild(div4);
list.appendChild(div5);
list.appendChild(div6);
list.appendChild(div7);
list.appendChild(div8);
list.appendChild(div9);
list.appendChild(div10);
return list;
}
posted @ 2019-05-23 19:43  A影子放風箏  阅读(1912)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css