SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: DOM Removing

  1. #1
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DOM Removing

    hi

    I use these two functions to totally remove a row from a table.

    Code:
    ONajaee.DOM.Navigation.removeElement = function (elem) {
        while (!elem.firstChild)
            removeElement(elem.firstChild);
    
        elem.parentNode.removeChild(elem);
    }
    ONajaee.DOM.Navigation.removeRow = function (sender) {
    
        var sender = window.event.srcElement;
        if (sender == null)
            return;
        var parent = sender.parentNode;
        while (parent.nodeName != "TR") {
            parent = parent.parentNode;
        }
        ONajaee.DOM.Navigation.removeElement(parent);
    }
    this is a working method if you have the following structure
    HTML Code:
    <table>
            <tbody>
                    <tr>
                        <td>
                            11
                        </td>
                        <td>
                            12
                        </td>
                        <td>
                            13
                        </td>
                        <td>
                            <div>
                                <input type="button" class="deleteButton" onclick='removeRow()' value='del' />
                                <span>hello world</span>
                            </div>
                        </td>
                    </tr>
    </tbody>
    </table>
    but whenever I put the input in a div element and add some text and clutter around this is failing.

    can anybody please help me?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by platipino View Post
    but whenever I put the input in a div element and add some text and clutter around this is failing.

    can anybody please help me?
    Sure thing - link us through to a test page where we can see the text and clutter version, so that we can help you find and solve the problem.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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