Last active
August 29, 2015 14:09
-
-
Save butchi/5ed75fa4909f41e31cf2 to your computer and use it in GitHub Desktop.
要素からコメントアウトを取り出す ref: http://qiita.com/butchi_y/items/78ef939cbcef4f108c66
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
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<!--hoge--> | |
foo | |
<!--piyo--> | |
bar | |
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> | |
</body> | |
</html> |
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
var $elm = $('body') | |
var $comment = $elm.contents().filter(function() { | |
return this.nodeType === document.COMMENT_NODE; | |
}); | |
var commentArr = $comment.map(function(i, elm) { | |
return elm.data; | |
}); | |
console.log(commentArr); |
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
var $elm = $('body') | |
var $comment = $elm.contents().filter(function() { | |
return this.nodeType === document.COMMENT_NODE; | |
}); | |
$comment.each(function(i, elm) { | |
console.log(elm.data); | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<!--hoge--> | |
foo | |
<!--piyo--> | |
bar | |
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> | |
<script src="main.js"></script> | |
</body> | |
</html> |
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
var $elm = $('body'); | |
var $comment = $elm.contents().filter(function() { | |
return this.nodeType === document.COMMENT_NODE; | |
}); | |
$comment.each(function(i, elm) { | |
console.log(elm.data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment