Get Text Inside HTML Comment Tag - jQuery Comments.js

Get Text Inside HTML Comment Tag - jQuery Comments.js
File Size: 5.63 KB
Views Total: 1408
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

Comments.js is a lightweight jQuery plugin which enables you to get the comments inside the HTML comment tag within your document.

How to use it:

1. Load the JavaScript file 'jQuery.comments.js' after jQuery library and the plugin is ready for use.

<script src="//"></script>
<script src="js/jQuery.comments.js"></script>

2. The plugin supports both single and multi-line html comments.

<!-- Single line comment -->


3. Get the text inside the html comment tag.

var myComments = $('#el').comments();

4. Parameters.

  • parseComment: If yo want to parse the comments to get only inside comments or get all the comment including brackets
  • separator: If you want to add a separator. Only in multilines comments
$.comments(parseComments, separator);

This awesome jQuery plugin is developed by Krato. For more Advanced Usages, please check the demo page or visit the official website.