Home › Forums › JavaScript › Detect selected text › Re: Detect selected text
June 13, 2010 at 9:02 am
#77799
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”);
});
});