Get Visible Text Nodes With The VisibleText jQuery Plugin
File Size: | 32.2 KB |
---|---|
Views Total: | 350 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
VisibleText is a jQuery plugin that gets a string of all aggregated visible text nodes from HTML element, jQuery object, or NodeList.
Similar to the jQuery's text() method but more flexible and powerful.
How to use it:
1. Load the main script jquery.visibleText.js
after jQuery.
<script src="/path/to/cdn/jquery.slim.min.js"></script> <script src="/path/to/jquery.visibleText.js"></script>
2. Get all visible text from an element you specify.
<p class="lead">Lorem ipsum <em>dolor</em> sit amet, consectetur adipiscing elit. Integer iaculis scelerisque mauris, vitae bibendum quam dictum vitae. Integer turpis ante, auctor at felis sit amet, interdum maximus turpis. </p>
$(function(){ var text = $('.lead').visibleText(); });
3. Output the text.
console.log(text);
This awesome jQuery plugin is developed by Krinkle. For more Advanced Usages, please check the demo page or visit the official website.