I used a div to set the text and remove anything that is not required for word/char count.
DEMO: http://jsbin.com/aneray/88/edit
function count(){
var $t = $('<div />').html($('textarea').val());
$t.find('style').remove(); //remove style content
txtVal = $t.text(); //fetch the text, ignore the tags
var words = txtVal.trim().replace(/\s+/gi, ' ').split(' ').length;
var chars = $.trim(txtVal).length; //trim any additional spaces, remove $.trim to include white spaces and additional space from tag line breaks
if(chars===0){words=0;}
$('#counter').html('<br>'+words+' words and '+ chars +' characters');
}
count();
$('textarea').on('keyup propertychange paste', function(){
count();
});