Web Analytics Made Easy -
StatCounter Remove span tags - CodingForum

Announcement

Collapse
No announcement yet.

Remove span tags

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          Thanks again Tinyscript for all your help.

          For anyone interested check this:

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

          thanks once again

          Comment

          Working...
          X