This code works fine here
It tries to find sml( and )sml in elements with the class uppercase and replace them with <span style="text-transform:none"> and </span>
but when I try to put all of that in one file, HTML file, it just won’t work !
Should I use something else instead of $(document).ready ? What is wrong ?
<html>
<head>
<script type="text/javascript">
<!--
$(document).ready(function () {
$('.uppercase').each(function() {
var end = false;
var s = $(this).html();
while(end == false) {
var p1 = s.indexOf('sml(');
var p2 = s.indexOf(')sml');
if (p1 != -1) { /* if '(' is found in the string */
var result = s.substring(0,p1);
result += '<span style="text-transform:none">';
result += s.substring(p1+4,p2);
result += '</span>'
result += s.substr(p2+4);
s = result;
} else {
end = true;
}
}
$(this).html(result);
})
})
-->
</script>
<style type="text/css">
<!--
.uppercase:hover {
text-transform:uppercase;
}
-->
</style>
</head>
<body>
<span class="uppercase">
everything uppercase except sml(this)sml and sml(this too)sml
</span>
</body>
</html>
You need to include a reference to jQuery before your
document.readycall: