Now that I’ve been able to enable search term highlighting using JS and CSS, I’d like to provide a button to turn off the highlighting on a page. I’ve spent several hours googling for answers, but ended up finding some very complicated answers that didn’t seem to apply.
My highlight script uses css and <span> tags to set the highlight. Here’s my code:
[code=html]<head>
<script type=”text/javascript”>
function removeHighlighting()
{
el = document.getElementById(‘searchhighlight’);
el.style.backgroundColor = #FFFFFF;
}
</script>
<style type=”text/css”>
<!–
.searchhighlight {
background-color: #FFFF00;
color: #000000;
}
–>
</style>
</head>
<body>
<p>A <span class=”searchhighlight”>test</span> sentence</p>
<input type=”button” value=”Remove Highlighting” onclick=”removeHighlighting()”/>
</body>
What is it I’m missing?