Is it possible to exclude some elements from parsing when using regular expression and .replace()?
- by Fletus Mefitis
<script language="javascript">
$("div.post-content , .parsedsig").each(function(){
if($(this).html().indexOf("[/tabulaScriptum]") != -1) {
pattern = /\[tabulaScriptum=(.*?)\]([^\[]*)\[\/tabulaScriptum\]/gi
$(this).html($(this).html().replace(pattern, "<div class='tabulaScriptum'><div class='tabulaNomen'>$1</div><div class='tabulaImpleo'>$2</div></div>"))
}
});
</script>
This script is working perfectly, except for one thing... I need not to replace [tabulaScriptum=][/tabulaScriptum] in certain elements. For example, I don't want to replace those "tags" in element that has class .code-box. Is it possible?
Clarification: element .code-box is located within .post-content.
Clarification #2: this script creates simple division spoiler. .tabulaScriptum is spoier's body, .tabulaNomen is spoiler's name and button which, in turn, reveals(or hides) .tabulaImpleo on click. Reveal\hide script is located in some other place, and I didn't post it here since it doesn't really matter.
Clarification #3: http://jsfiddle.net/PRtsw/1/ fiddle.