$('li.cat_level_1 a').each(function () { this.innerHTML = this.innerHTML.replace( /^(.+?\s)/, '<span>$1</span>' ); });