JSFiddle - React, Tailwind, and code Playground
by Timmy Willison
HTML
<table id="one"><tr><th>fred</th></tr></table>
<table id="two"><tr><td>fred</td></tr></table>
JavaScript
console.log($('#one').find('th[colspan!=""]').length); //Returns 1
console.log($('#one').find('th[colspan]').length); //Returns 1
console.log($('#two').find('td[colspan!=""]').length); //Returns 1
console.log($('#two').find('td[colspan]').length); //Returns 1
$('#one').find('th').each(function() {
console.log('colspan:' + $(this).attr('colspan'));
});