[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread Scott Sauyet
On Jan 18, 4:55 pm, Scott Sauyet wrote: > It's a >         very typo: difficult -- Scott

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread Scott Sauyet
On Jan 18, 11:46 am, Mircea wrote: > Yes, I want to be able to select a part of the text and add a span to > it. Can this be done? It's a very difficult problem to solve in the general case. Imagine this markup: It's a very difficult problem to solve in the general c

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread Mircea
Thanx a lot Morning. It does work this way All the best!

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread MorningZ
the variable name/reference is "$spn" so it would be: $("p").append($spn); your line of $("p").append("spn") does exactly what you told it to do :-) On Jan 18, 2:34 pm, Mircea wrote: > I've added > > $("p").append("spn") > > It ads only the text spn at the bottom of the text. I probably di

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread Mircea
I've added $("p").append("spn") It ads only the text spn at the bottom of the text. I probably did not used the append function right to pass the variable to p. Thanx

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread MorningZ
it probably is working, but you failed to *do* anything with the generated tag... that's why i added as a comment: // append/set this '$spn' inside another DOM object On Jan 18, 12:29 pm, Mircea wrote: > Thanx for the code. > It does not work to me. I am a newbye is JQuery, please excuse the >

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread Mircea
Thanx for the code. It does not work to me. I am a newbye is JQuery, please excuse the dumb questions... This is my code and markup: http://www.w3.org/TR/html4/loose.dtd";> http://code.jquery.com/jquery-latest.js";> http://jqueryui.com/latest/ui/ ui.core.js"> http://jqueryui.com/l

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread MorningZ
yes, it indeed is selection = getSelectedText(); if(selection.length >= 3) { $(this).html($(this).html().addClass("selected"); } to selection = getSelectedText(); if(selection.length >= 3) { var $spn = $("").html(selection).addClass ("selected"); // append/set this '$spn' inside

[jQuery] Re: Select part of text and add a CSS class

2010-01-18 Thread Mircea
Yes, I want to be able to select a part of the text and add a span to it. Can this be done? Thank you.