Created
September 20, 2016 06:50
-
-
Save lirongfei123/1784a18153908e5410581cf351771773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cloneImg (elem) { | |
var imgNode = document.createElement("div"); | |
var attributes = elem.attributes; | |
for (var i in attributes) { | |
if(!attributes.hasOwnProperty(i)) { | |
continue; | |
} | |
var attr = attributes[i]; | |
if(attr.name == 'class') { | |
imgNode.className = attr.value; | |
continue; | |
} | |
imgNode.setAttribute(attr.name, attr.value); | |
} | |
return imgNode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment