HTML CODE
<div id="border"> <textarea id='text'></textarea> </div> <button id="count">Count</button> <div id="result"> Words: <span id="wordCount">0</span><br/> Total Characters(including trails): <span id="totalChars">0</span><br/> Characters (excluding trails): <span id="charCount">0</span><br/> Characters (excluding all spaces): <span id="charCountNoSpace">0</span> </div>
JAVASCRIPT CODE
counter = function() { var value = $('#text').val(); if (value.length == 0) { $('#wordCount').html(0); $('#totalChars').html(0); $('#charCount').html(0); $('#charCountNoSpace').html(0); return; } var regex = /\s+/gi; var wordCount = value.trim().replace(regex, ' ').split(' ').length; var totalChars = value.length; var charCount = value.trim().length; var charCountNoSpace = value.replace(regex, '').length; $('#wordCount').html(wordCount); $('#totalChars').html(totalChars); $('#charCount').html(charCount); $('#charCountNoSpace').html(charCountNoSpace); }; $(document).ready(function() { $('#count').click(counter); $('#text').change(counter); $('#text').keydown(counter); $('#text').keypress(counter); $('#text').keyup(counter); $('#text').blur(counter); $('#text').focus(counter); });
DEMO
Check this link http://jsfiddle.net/vetri/szfgmekm/1/
SunScoop Kids 100% Mineral Sunscreen Lotion SPF 30+ PA++++ | Paediatrician Recommended | Prevents Tanning & Sunburn | Sweat & Water Resistant | Safe for Sensitive Skin | for 1+ Years | 75 gm
₹469.00 (as of January 13, 2025 21:52 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Philips Avent Pacifier Ultra air | Lets Your Baby's Skin Breathe | Orthodontic & BPA Free | 2 Pack | 6-18m | SCF085/61
₹543.00 (as of January 13, 2025 21:52 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)TONY STARK Big Size Unicorn Glow in The Dark Blanket for Kids, 0-15 Years |200x152 Cm| Soft Flannel Fleece Throw, Cozy & Warm All-Season Radium Blanket for Boys & Girls – (Multicolor Unicorns)
₹949.00 (as of January 13, 2025 21:52 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)MamyPoko Pants All Night Absorb Baby Diapers, Large (L), 44 Count 9-14 kg
₹416.00 (as of January 13, 2025 21:52 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)CAREIT Playards|Playpen for Kids up to 4 Years, Spacious 150x180 cm Baby Play Yard with Safety Lock & Hand Grip, Thick Padding & 360° Mesh Visibility, Portable Activity Center for Toddlers - LightGrey
Now retrieving the price.
(as of January 13, 2025 21:52 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)