When the user selects the text, I need to check two things before completing my last task:
- Is the selected text selected in the main div.entry-content? I have done it.
- Is this highlighted text outside or crazy any highlighted css class? I need help here.
Basically:
- If "his early acquaintance" is selected, return false
- If "head of the first South African boerboel club" is selected, return the truth
HTML source:
<p>
<span id="subject-47" class="subject highlighted">Semencic credits his early familiarity with the breed to his own travels to South Africa<span class="count">4</span></span>, but especially to his frequent correspondence with the head of the first South African Boerboel club, one Mr. Kobus Rust. <strong>The Boerboel Breeders Association was established in 1983</strong> in the Senekal district of the Free State with the sole objective of ennobling and promoting the Boerboel as a unique South African dog breed.
</p>
My current Javascript (works, but I need this last validation function)
$( window ).load(function() {
$(document.body).bind('mouseup', function(e){
snapSelectionToWord();
var txt = getHTMLOfSelection();
var contentPos = $('.entry-content').html().indexOf( txt );
if( contentPos > 0 ) {
}
});
});
source
share