jQuery, find if element has any text

$("span.col").each(function(){
    if (!$(this).text().trim().length) {
        $(this).addClass("foo");
    }
});

http://jsfiddle.net/cfgr9/1/

Obviously instead of adding a class you can do as you like, return the object etc

UPDATE: Removed strange hidden character after final semicolon that caused js error.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)