我是JS的新手,我得到了这段代码。我只需要添加第3个按钮,但在添加“array7”后我被卡住了。有什么想法吗?我没有像这样构建一个按钮 -
(function () {
var objDiv = document.getElementById('cas4_ileinner'); //declaring an object and assign it to the element on the page
if (objDiv) {
var name = document.getElementById('cas4_ileinner').innerHTML; //declaring an object and assigning the HTML code contained in the element on the page
var array3 = new Array(); //array to split the hmlt code from the account name
var array4 = new Array(); //array to split the hmlt code from the account name
var array5 = //array of guardian account names
['Census',];
var array6 = //array of Smart customers
['Jane',];
array3 = name.split('>'); //splitting the account from the other HTML code
array4 = String(array3[1]).split('<'); //splitting the account from the other HTML code
//window.alert(array4);
var content4 = 'null'
if (array5.indexOf(array4[0]) > - 1) { //comparing the account name in the account name array to the string split from the HTML element to each other.
content4 = name + '<a target="_blank" href="helloworld.com" <span class="btnPrimary" style="color:white; background-color:red" style="margin: 0px 0px 6px 6px; padding-top:4px;">Guardian</span></a>';
objDiv.innerHTML = content4; //update the element to include a Guardian Account
}
if (array6.indexOf(array4[0]) > - 1) {//comparing the account name in the account name array to the string split from the HTML element to each other.
if (content4 != 'null'){
//window.alert(content4);
var content5 = content4 + '<a target="_blank" href="goodbyeworld.com" <span class="btnPrimary" style="color:black; background-color:yellow" style="margin: 0px 0px 6px 6px; padding-top:4px;">Smart</span></a>';
objDiv.innerHTML = content5; //update the element to include a Smart case
// window.alert(content4);
} else {
var content5 = name + '<a target="_blank" href="goodbye world.com" <span class="btnPrimary" style="color:black; background-color:yellow" style="margin: 0px 0px 6px 6px; padding-top:4px;">Smart</span></a>';
objDiv.innerHTML = content5; //update the element to include a Smart case
//window.alert(content5);
}
}
}
})();