JSFiddle - React, Tailwind, and code Playground

by George Y

HTML

<span data-editableproperty="text" style="display:none"><span style="font-family: ABeeZee;"><span style="font-size: 39px;"><em>fdsfdsfdsjkljkl</em></span></span><span style="font-style: italic; font-family: 'Advent Pro';"><br></span><span style="font-family: Helvetica,sans-serif;"><strong>klk;lk;lk;lfdsf<br>fsdfsd<span style="font-style: italic;"><br>fsd<br>f<br></span>sd
<br>f</strong>
</span>
</span>


<span data-editableproperty="text2"><strong>Hello</strong> <span style="font-family: Open Sans;"><span style="font-weight: 600;">World</span></span>
<br>Hello2 <strong>world2</strong>
<br><span style="font-family: Open Sans;"><span style="font-style: italic;"><span style="font-weight: 700;">Helloworld3</span></span>
</span>
<br><span style="font-family: Impact,sans-serif;">Hello4</span> <span style="font-family: Arial Black,sans-serif;">world</span> 4, <span style="font-family: HelveticaNeue-Bold, HelveticaNeue, Helvetica Neue, Helvetica Neue LT Std, Helvetica, Verdana, Arial, sans-serif;"><span style="font-weight: 700;">hello5</span></span>
</span>

JavaScript

var divs = $('span[data-editableproperty="text2"]').children().toArray()
console.log(divs)
for (var i = 0; i < divs.length; i++)
  isBold(divs[i]);

function isBold(node) {

  var childNodes = node.childNodes;
  // console.log(node)
  console.log(childNodes)
  for (var i = 0; i < childNodes.length; i++) {

    console.log(childNodes[i].innerHTML)
      //  console.log(typeof(childNodes[i]))

    if (childNodes[i].nodeType == 1) {
      console.log(getComputedStyle(childNodes[i], null).getPropertyValue('font-weight'))
    }
    
     if (childNodes[i].nodeType == 3 && childNodes[i].parentNode.tagName == 'STRONG') {
     	console.log('strong-type-3')
     }
    
    
    // 

    //for now just ignore the rest
    if (childNodes[i].nodeType == 3 && childNodes[i].parentNode.tagName == 'STRONG' || childNodes[i].parentNode.outerHTML.match(/font-weight:\s*([^';">\s]+)/gi) !== null) {
      // return true;
    }
    if (childNodes[i].nodeType != 3 && (
        childNodes[i].tagName == 'B' || childNodes[i].tagName == 'STRONG')) {
      // return true;
    } else {
      //  return false;
    }
  }
}