SLR wrote:
>
> First off, I'm also new to jQuery so I apologize if my solution is the
> best way to do this. Anyways, here's what I came up with
>
It looks like we are not far from my goal. I tested a (slightly modified)
version of your suggestion and it returns me something more satisfying than
my previous attempts, but my test implementation did not restrict the
alert() to just what I had selected. Instead, it gave what was enclosed in
specified classes, with html syntax and all, which is really nice.
Maybe I've not read your code as I should (being a novice with the syntax),
but I see nowhere a hint of what part of the text is actually selected.
Now if we can find a way to restrict the returned value to the _selected_
text, I'll finally have what I've been searching for for days.
Cheers,
Stéphane
(Here's my test case, just in case – how do I restrict parts of the HTML to
be interpreted in my snippets?)
<html>
<head>
<script type="text/javascript" src="jquery/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a.go").click(function(){
alert($("span.loremipsum").eq(0).html()); // Alerts
contents of first
"lorum" p tag
return false;
// Cancels link from being followed
});
});
</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> # shoot </p>
</body>
</html>
--
View this message in context:
http://www.nabble.com/-Beginner-alert--How-do-I-output-the-selected-part-of-the-DOM-in-a-web-page-in-a-JS-alert%28%29--tp20755509s27240p20762618.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.