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/
HSR Inflatable Baby Bathtub with Built-in Air Pump, Newborn to Toddler Bath Tub 0-36 Months, Portable Travel Shower Basin with Back Support, Deflates and Folds Easily (0-36 Months)
₹849.00 (as of July 1, 2025 20:03 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.)StarAndDaisy Kids FoldableWardrobe with Cover & Drawers/Portable Almirah for Clothes, Shoes, Accessories/Space-Saving Closet with Side Pockets & Hanging Rod (Elegance)
₹3,698.00 (as of July 1, 2025 20:03 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.)Huggies Complete Comfort Wonder Pants | Pant Style Baby Diapers XL Size, 56 Count | India's Fastest Absorbing Diaper, Patented Dry Xpert Channel, Ideal for 12 to 17 Kgs
₹735.00 (as of July 1, 2025 20:03 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.)Baby Disposable Diaper Bags with Dispenser, Waste Bags 6 Refill Rolls/90 Bags, Convenient and Quick Diaper Disposal, Unscented Leak & Odors Proof Diaper Trash Bags for Newborn Diapers (6 Roll + Case)
₹279.00 (as of July 1, 2025 20:03 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.)BABYKINS Remote Teether Toy for Babies | Soft Silicone | BPA-Free | 3+ Months | Shape & Color Learning | Black
Now retrieving the price.
(as of July 1, 2025 20:03 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.)