Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Remove span tags

    Hi,

    Basically I have a button which when clicked creates a set of span tags around highlighted text. (as shown below).
    onMouseOver should call a function RemoveTags(event) which should remove these tags? How can i do this?

    <span onMouseOver = "this.style.color = 'Red'; RemoveTags(this)" > the dog and the cat</span>

    kind regards

    Chris

  • #2
    Regular Coder Actinia's Avatar
    Join Date
    Feb 2007
    Location
    Essex, UK
    Posts
    250
    Thanks
    1
    Thanked 23 Times in 22 Posts
    It is not clear what you are actually doing here. Could we see the code that selects the text? I presume that this code adds the span tags and inserts the onmouseover text as well. Why do you want to remove the span tags? If you mouseover and the colour changes, then it will stay changed. Do you have code for RemoveTags? If so could we see it.

    If you remove the <span> tags, then the span element you are styling will no longer exist, and I would not like to predict what (if anything) the browser DOM would make of it.

    John

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    with reference to "Could we see the code that selects the text?" :

    Couldn't I use "this" passed through "Removetags(this) ?

    I tried somehting like this:

    this.parentNode.removeChild(this);

    but it removes everything including the text. I want the text to remain.

    thanks

    chris

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    chris, I showed you the method.
    here's the link
    http://h1.ripway.com/stirfry/javascr...aretImage.html
    run this script. Firefox only, sorry it needs the IE tuning, but I had to resolve an issue with the removed elements interupting the next selections.
    Click on the box to start.
    it puts an a span with the index number and a starting image in front of the selection and it piuts and image at the end of the slection.... then 2 seconds later the script takes them back out!! It's exactly what you want to know! View the page source, or save the page.

  • Users who have thanked TinyScript for this post:

    csam0003 (04-08-2009)

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks again Tinyscript for all your help.

    For anyone interested check this:

    http://www.webdeveloper.com/forum/sh...231#post996231

    thanks once again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •