-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeTag.js
More file actions
23 lines (19 loc) · 700 Bytes
/
Copy pathmakeTag.js
File metadata and controls
23 lines (19 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function makeTag(tag,tContent,tID,tClass,tValue,tAlt,tOther){
var tagAttributeNames = ['','','id','class','value','alt'];
var tagAttributes, tagOutput;
tagAttributes = '';
for(var i=0; i<arguments.length; i++) {
if(i > 1 && i < 6 && arguments[i] != undefined && arguments[i] != ''){
tagAttributes += tagAttributeNames[i]+'="'+arguments[i]+'" ';
}
}
if(tOther == undefined){ // don't insert undefined
tOther = '';
}
if(tContent == undefined || tContent == ''){ // is this tag self-closing?
tagOutput = '<'+tag+' '+tagAttributes+' '+tOther+' />';
}else{
tagOutput = '<'+tag+' '+tagAttributes+' '+tOther+'>'+tContent+'</'+tag+'>';
}
return tagOutput;
}