Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 28th, 2007, 06:42 AM
Authorized User
 
Join Date: Apr 2007
Location: Chandigarh, , India.
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Default How to get nodes from Selection/Range

Hi,
Is it possible to get the nodes from the Range object?
My html consists of multiple div and span nodes, for example:
<div>start<span class="blue">text</span><span class="red">more text</span><span class="green">still more text</span>end</div
If the user selects the text between start and end and selects a class from a combo, I need to change the class of each span in the selection.
How can I get list of nodes from the Selection or Range?
Thanks,
Kapil
Reply With Quote
  #2 (permalink)  
Old June 17th, 2007, 07:38 AM
Authorized User
 
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Accessing list of selected nodes is not possible in this way, but I think that using 'htmlText' property of 'TextRange' object may be usefull in this situation. You can access HTML representation of selected text of document using 'document.selection.createRange().htmlText'.

This property give you a plain html code of selected portions of document. If your span elements have specific id (or specific pattern in their id), you can search this string and find what span element have been selected by user and access them by document.getElementById('span id');
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to value in b/n nodes Swetha XSLT 1 May 20th, 2008 12:20 PM
Navigate through nodes abelmirma XML 1 May 7th, 2005 07:32 AM
Range selection keithd Excel VBA 7 April 7th, 2005 11:29 AM
Exclude Nodes seanhaggerty XSLT 1 February 3rd, 2005 06:00 AM
Grouping Nodes shoei78 XSLT 3 May 28th, 2004 10:34 PM



All times are GMT -4. The time now is 02:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.