Hi there,

Where in the example is the class 'third' you mentioned?

and what is this supposed to do?
<p> javascript:getActiveText(); Alert me!</p>

The best I can do is point you to 
https://developer.mozilla.org/en/DOM/Selection.
Read on about the selection object and range object, and you'll see
that this is not as simple as it looks! You're still very far from
accomplishing what you want. May I ask what is the purpose of it?

cheers,
- ricardo

On Nov 30, 2:06 pm, stephane_r <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Consider the code snippet at the end of the post.
>
> It alert()s me by returning the selected text.
>
> The problem is that window.getSelection() only returns plain text. No
> indication of the html tags, of the classes, nor any kind of DOM.
>
> I think that jQuery has something more complete than window.getSelection(),
> but I was not able to find it reading the docs and searching Google. I'm a
> beginner with jQuery, as you've probably figured right now.
>
> The ultimate goal would be to filter the selection so that only text
> enclosed in given classes (say loremipsum and third in my example) are
> returned. I'd take it as a bonus, but I can figure this part by myself
> server-side.
>
> Cheers,
> Stéphane
>
> <html>
> <head>
> <script type="text/javascript">
> function getActiveText(e) {
>         var text = window.getSelection();
>         alert(text);}
>
> </script>
> </head>
> <body>
>         <p class="lorem">Lorem ipsum dolor sit amet, magna massa aliquet in
> libero, a suscipit suspendisse ac penatibus, lectus donec consequat, sed
> justo</p>
>         <p> javascript:getActiveText(); Alert me! </p>
> </body>
> </html>
>
> --
> View this message in 
> context:http://www.nabble.com/-Beginner-alert--How-do-I-output-the-selected-p...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to