JSFiddle - React, Tailwind, and code Playground

by alexdickson

HTML

<li id='list_id'>
    &nbsp;&nbsp;<input type="checkbox" name="check"><span>&nbsp;</span>good
    </li>

JavaScript

var listItem = $('#list_id');
    
    var clone = listItem.clone();
     
    clone.find('*').remove();
    
    matches = clone.html().match(/&nbsp;/g);
    
    alert(matches.length);