I'm trying to create a script which allows me to replace text or html tags in realtime. Here is what I got so far.
PHP Code:
$str = '<b>Hey!</b> This is a <b>test!</b>';
echo '<div id="strDiv">';
echo $str;
echo '</div>';
Code:
$('#rbtn').click(function() {
$('#strDiv').each(function() {
var from = '<b>',
text = $(this).html().replace(from, '');
$(this).html(text);
});
});
This works if I only have one replace to work with, and by the way... It. only replaces the first <b> and I want it to replace all <b> tags in the string!
I want to make an multiple selectbox with some options to replace from the string like this:
PHP Code:
<select name="test" multiple="multiple">
<option><?=htmlentities('<b>');?></option>
<option>Hey</option>
<option>This</option>
<option>!</option>
</select>
So if I hit the first option it would remove/replace all incidents of this option in the string. If I deselect it again I want it to reinsert it into the string again.
I'm a bit stuck and need some help. Please....
Thanks in advance ;-)