Some research Is always good and even more rewarding when you solve it by urself.
Anyhow here is a fast mashup:
HTML
<span>test1 test1 test1 test1 test1 test1 test1</span></br>
<span>test2 test2 test2 test2 test2 test2 test2</span></br>
<span>test3 test3 <span class="target">[test3 test3]</span> test3 test3 test3</span></br>
<span>test4 <span class="target">[test4 test4 test4 test4]</span> test4 test4</span></br>
<span>test5 test5 test5 test5 test5 test5 test5</span></br>
CSS
.marked{
background-color:blue;
font-weight: bold;
color:white;
}
Script
I know you asked for pageload but for future use you can do this on a click event:
$(function() {
$(".target").on("click",function() {
$(this).addClass("marked");
var str = $(this).text();
str = str.replace(/[[\]]/g, "");
$(this).text(str);
});
})
Can read more about that here
Fiddle
On page load:
$(function() {
$(".target").each(function(){
var str = $(this).text();
str = str.replace(/[[\]]/g, "");
$(this).addClass("marked").text(str);
})
})
onloadFiddle