JQuery find and replace text

Hi All

I’m trying to get to grips with JQuery, and am stuck on something simple - can’t seem to find the answer on google which is a bit surprising…

I’m trying to do a simple find and replace on all paragraphs on a page. I’ve tried a few ways and none seem to work. I thought of doing something like this:

$("p").each(function (i) {
	this.html(this.html().replace('*****','<span class="stars stars5">* * * * *</span>'));
});

But that doesn’t seem to work. Anyone know how to do this?

Thanks in advance and sorry if it’s a dumb question!


		<script type="text/javascript" >
			$(document).ready(function(){
				
				$('p').each(function(i){
					alert($(this).html().replace('*****','<span class="stars stars5">* * * * *</span>'));			
					
				})	
				
			})
			
		</script>



$("p").each(function () {
	$(this).html(this.html().replace('*****','<span class="stars stars5">* * * * *</span>'));
});

Aha - thanks a lot! If anyone else needs this code, I did just need to add one thing to the above:

$(this).html($(this).html().replace('*****','<span class="stars stars5">* * * * *</span>'));
});