The glue code is converting your jQuery object.
var text = $('div.selectable')[0].getSelection();
alert(text);
[0] takes the first element you selected and "removes" the jQuery
methods, "replacing" them with the usual DOM methods.
I don't know how supported .getSelection() is so this code may not
work. But you can do something similar like
var text = $('div.selectable')[0].innerHTML;
Now if you wanted to do this for all div.selectable, you could do:
$('div.selectable').each(function() {
var text = this.getSelection(); //or innerHTML or so on
alert(text);
})
On Dec 2, 6:04 am, stephane_r <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Sorry if my question is not worded properly, I'm new to jQuery and still do
> not understand its syntax. I've read a lot of examples and it did not help
> me much.
>
> I've got this really simple JS function:
>
> function getActiveText(e) {
> var text = window.getSelection();
> alert(text);
>
> }
>
> That returns the raw selection in an xhtml page.
>
> Now I want to limit what it returns to only what is enclosed in divs of the
> class "selectable".
>
> jQuery has the $('div.selectable') selector which selects all <div> elements
> with a class name of "selectable".
>
> What I'm missing is the glue code between my function and jQuery's selector.
>
> From there, I should be able to go further with jQuery. Now I'm just getting
> confused.
>
> Cheers,
> Stéphane
> --
> View this message in
> context:http://www.nabble.com/First-steps-in-jQuery%3A-trying-to-figure-the-s...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.