Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Detect selected text Re: Detect selected text

#77799
jamygolden
Member

Yes you can do that. If you mean add a class of .selected to the bold tag when you hover on <p>. – And I’m asuming you have wrapped the bold text within a "b" or "strong" tag.
html:

Code:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tincidunt varius augue ac laoreet.

jquery/javascript

Code:
$(document).ready(function(){

$(“p”).hover(function() {
$(this).children(“b”).toggleClass(“selected”);
});

});