Removing br node after div with javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asafok
    New Member
    • Aug 2007
    • 10

    Removing br node after div with javascript

    i have the attached code is the site i'm working on and i need to remove the <br/>
    node that comes after the " <div id="win_233906" ... "
    my question is : how can i get access to the <br/> and how can i replace it with an empty string or even remove it completely.

    the coed:

    [HTML]<table>
    <tr>
    <td valign="top" style="width: 140px; direction: rtl; background-color: rgb(153, 203, 228);
    height: 321px;">
    <div id="win_233906 " style="height: 177px" onclick="return win_233906_oncl ick()">
    <div id="win_header_ 233906" style="backgrou nd-image: url(index432.jp eg);">
    <a class="changeLi nk14" href="/site/flash/flashList.asp?l ine_id=233906"> חדשות ועדכונים</a>
    </div>
    <div id="win_flash_2 33906">
    <ul>
    <li><a class="changeLi nk14" href="/site/flash/flashDetail.asp ?flash_id=19196 9">ניסיון
    2</a> </li>
    <li><a class="changeLi nk14" href="/site/flash/flashDetail.asp ?flash_id=19196 8">ניסיון
    1</a> </li>
    </ul>
    </div>
    </div>
    <br /> <------------ need to remove this!
    </td>
    </tr>
    </table>

    [/HTML]
    it's very urgent so i really need your help!!!
    i'll appreciate if you could send your answers to this mail : [EDIT]
    Last edited by gits; Dec 4 '07, 07:51 AM. Reason: added code tags ... drop email address
  • Dasty
    Recognized Expert New Member
    • Nov 2007
    • 101

    #2
    assign id to your <br /> element like:

    Code:
    <br id=myid />
    so you can remove it by:

    Code:
    var obj = document.getElementById('myid');
    obj.parentNode.removeChild(obj);
    If you can not add id to tag, use getElementsByTa gName instead. But it will be hard to find right one in the array.

    Comment

    • RMWChaos
      New Member
      • Oct 2007
      • 137

      #3
      Originally posted by asafok
      …“i'll appreciate if you could send your answers to this mail : [EDIT].”
      Just as an FYI…it’s better to go to your control panel and set your post to “immediate email” rather than ask other members to send the response to you in email. The reason for doing this is two-fold: 1) responses should be posted to the site so that everyone can benefit them; this saves a great deal of time for those looking for the answer to the same question you’ve asked, and you benefit from others posts as well. 2) It takes extra time for members to email you their response, and you might not get the responses you are looking for because many people who do not know you may not wish to share their email address with you.

      Dasty's response looks like the best way to do it.

      Good luck,

      RMWChaos
      Last edited by gits; Dec 4 '07, 07:51 AM. Reason: drop email

      Comment

      • asafok
        New Member
        • Aug 2007
        • 10

        #4
        about the mail i apologize you're correct....
        as to the <br/>... i'm using a management system that i don't have access to its code. i can't assign an id to the node.
        is there a way to find the next node in line and deal with it? i know the id of the DIV element that comes before the <br/>.

        Comment

        • asafok
          New Member
          • Aug 2007
          • 10

          #5
          i have another question ... i tried to give the div "win_233906 " a background image at the bottom with css code:

          Code:
          background-image:url(\imgs\bottomRound.jpg);
          background-position:bottom;
          but for some reason i can't see the pic in IE7 or FireFox v2....
          can you help me?
          Last edited by gits; Dec 4 '07, 07:54 AM. Reason: added code tags

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            hi ...

            i've removed your email adress from the posts ... its for your own security and at least against the posting guidelines ... i think you won't get spammed or something like that ... so please: DON'T post your email-adress in the forum

            kind regards

            Comment

            • RMWChaos
              New Member
              • Oct 2007
              • 137

              #7
              Originally posted by asafok
              about the mail i apologize you're correct....
              as to the <br/>... i'm using a management system that i don't have access to its code. i can't assign an id to the node.
              is there a way to find the next node in line and deal with it? i know the id of the DIV element that comes before the <br/>.
              asafok,

              As long as the HTML code doesn't change, you can use the other method Dasty mentioned.

              Essentially, what you want to do is get the parent element using getElementsByTa gName(), then select the node number. So if the <br/> node is the 4th node under the parent, then it would look something like this:

              [code=javascript]
              // replace 'parentName' with the actual parent of the node to remove
              var parent = document.getEle mentsByTagName( 'parentName');

              // first node is 0, second is 1, etc...where 3 is the 4th node to remove
              var obj = parent[3];

              // now put it all together
              obj.parentNode. removeChild(obj );
              [/code]

              Just remember, if you don't own the site, then it may change, and you will have to change your code to match.

              Comment

              • RMWChaos
                New Member
                • Oct 2007
                • 137

                #8
                Originally posted by gits
                hi ...

                i've removed your email adress from the posts ... its for your own security and at least against the posting guidelines ... i think you won't get spammed or something like that ... so please: DON'T post your email-adress in the forum

                kind regards
                LOL, I guess I forgot to list the most important reason! =D

                Comment

                • asafok
                  New Member
                  • Aug 2007
                  • 10

                  #9
                  thanks all i will use your tips...

                  Comment

                  Working...