JSFiddle - React, Tailwind, and code Playground

HTML

<table id="one"><tr><th>fred</th></tr></table>
<table id="two"><tr><td>fred</td></tr></table>

JavaScript

alert($('#one').find('th[colspan!=""]').length); //Returns 1
alert($('#one').find('th[colspan]').length); //Returns 1

alert($('#two').find('td[colspan!=""]').length); //Returns 1
alert($('#two').find('td[colspan]').length); //Returns 1

$('#one').find('th').each(function() {
    alert('colspan:' + $(this).attr('colspan'));
});