Highlighting text with class
by crduling
HTML
<div>
<span class='highlighted'>Selecting this text should make this message appear if text that already contains class is highlighted</span>. More random text.
</div>
CSS
.highlighted {
background-color: lightGrey;
}
JavaScript
$("div").click(function() {
checkIfTextisAlreadyHighlighted();
});
function checkIfTextisAlreadyHighlighted() {
var sel = window.getSelection();
if (sel) {
alert("This text contains the class *class name here* and cannot be highlighted.");
}
}