удаление Элемента из ХТМЛ
Доброго времени суток
Помогите пожалуйста. Мне надо удалить элемент <div id="card">*ТУТ чтонибудь*</div> с JS особо не дружу... курение мануалов не помогло... попытался сделать следующие, но не помогло card = document.getElementById("card"); card.removeNode(false); |
var card = document.getElementById("card"); card.parentNode.removeNode(card); |
Riim, спасибо)))
|
Riim, тут проблемка, данный код еще грохает его родителя.... можно от этого как нибудь избавиться????
|
Цитата:
|
Riim, удаляется...
у меня идет <div style="margin-left: 15px;"> <div style=""> <a href="javascript:showcomp(7)">ТЕСТ</a> <div style="position: absolute; min-width: 150px; width: 150px; min-height: 150px; height: 150px; background-color: #818181; z-index: 50; margin-top: 15 px;" id="card"> asdasdasd <div align="right"> <a href="javascript:closing2()">Закрыть окно</a> </div> </div> </div> </div> в результате пропадает еще строка ТЕСТ заменил на card.parentNode.removeChild(card); стало нормально |
или у меня еще было
[html] <p> <div>Тут большой текст</div> <div id="card">Это должно удалиться</div> </p> [html] после использование скрипта, пропадало все что находилось в <p></p> |
[quote=Tinvul;24244]или у меня еще было
<p> <div>Тут большой текст</div> <div id="card">Это должно удалиться</div> </p> после использование скрипта, пропадало все что находилось в <p></p> |
Выложи весь код.
|
<html> <head> <style> </style> <style type="text/css"> .content {text-indent: 1.5em; text-align: justify;} .content div {text-indent: 1.5em; text-align: justify;} .content p {text-indent: 1.5em; text-align: justify;} </style> <script type="text/javascript"> var request = null; try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = null; } } } if (request == null) alert("Ошибка создания запроса. Повторите пожалуйста позже. Если данная ошибка снова повторится, то сообщите администратору сайта"); function showcomp(idcomp) { var url = "assets/snippets/bs_catalog/view_company.php?idcomp="+idcomp; request.open("GET", url, true); request.onreadystatechange = updatePage; request.send(null); } function updatePage() { if (request.readyState == 4) { /* Get the response from the server */ var customerAddress = request.responseText; /* Update the HTML web form */ document.getElementById("card").innerHTML = customerAddress; } } </script> <script type="text/javascript"> function closing2() { var card = document.getElementById("card2"); card.parentNode.removeNode(card); } </script> <style type="text/css"> a {color: #006897; text-decoration: none;} body {color: #575757;} h1 {font-size:20px; color: #000000} h2 {font-size:18px;} h3 {font-size:14px;} </style> <script type="text/javascript" language="JavaScript1.2" src="menu.js"></script> </head> <body style="margin: 0px 0px 0px 0px; min-width: 950px; font-family:Arial; font-size:12px;"> <div style="height: 190px;"> <a href="/bs/"><img src="system_img/logo_bs.gif" width="519" height="190" hspace="0" vspace="0" border="0" /></a> </div> <!-- Левый блок --> <div style="width: 180px; height: auto; position: absolute; left: 15px;"> <div style="width: 180px; min-width: 180px; max-width: 180px; margin-top:25px;"> <div>Свежий № <a href="index.php?id=48" style="text-decoration: underline;">Апрель-май 2009</a></div> <div style="margin-top: 20px;"><div><div style="margin-top: 5px;"><a href="/bs/index.php?id=2" title="Власть и экономика" style="">Власть и экономика</a></div> <div style="margin-top: 5px;"><a href="/bs/index.php?id=7" title="От первого лица" style="">От первого лица</a></div> <div style="margin-top: 5px;"><a href="/bs/index.php?id=9" title="Коммунальный вопрос" style="">Коммунальный вопрос</a></div> <div style="margin-top: 5px;"><a href="/bs/index.php?id=15" title="Научная среда" style="">Научная среда</a></div> <div style="margin-top: 5px;"><a href="/bs/index.php?id=16" title="День геологии" style="">Геология</a></div> <div style="margin-top: 5px;"><a href="javascript:open(38)" title="Деловой портрет региона ">Деловой портрет региона</a></div><div id="38" style="display: none; margin-left: 5px; margin-top:7px; margin-top: 7px;"><div><div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=39" title="Амурская область" style="">Амурская область</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=46" title="Еврейская автономная область" style="">Еврейская автономная область</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=51" title="Магаданская область" style="">Магаданская область</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=58" title="Камчатский край" style="">Камчатский край</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=66" title="Приморский край" style="">Приморский край</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=78" title="Республика Саха (Якутия)" style="">Республика Саха (Якутия)</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=101" title="Сахалинская область" style="">Сахалинская область</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=113" title="Хабаровский край" style="">Хабаровский край</a></div> <div style="margin-top: 0px; margin-left: 10px;"><a href="/bs/index.php?id=128" title="Чукотский автономный округ" style="">Чукотский автономный округ</a></div> </div></div> <div style="margin-top: 5px;"><a href="/bs/index.php?id=130" title="Бизнес-предложения" style="">Бизнес-предложения</a></div> </div></div> <div style="margin-top: 35px; text-align:center; background-color:#f15a23;"><h2 style="color: #FFFFFF; padding-top: 5px; padding-bottom: 5px;">Бизнес - предложения</h2></div> <div>Рассылка<br></div> <div><h2>Наши партнеры:</h2></div> <div style="margin-top: 5px;"><img src="left_banners/asp_logo_100.gif" hspace="0" vspace="0" border="0" /></div> </div> </div> <!-- Правый блок --> <div style="width: 210px; right: 15px; position: absolute; height: auto;"> <div><a href=""><img src="" alt=" Сантехника" /></a></div><div><a href=""><img src="" alt=" Вентиляционное2" /></a></div> </div> <!-- Центральный блок --> <div style="width: auto; left: 220px; right: 250px; position: absolute; padding: 0 0 0 0; border: 0px; height: auto;"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="center" width="*"> </td> <td align="center" width="480"> <table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td width="160" align="center" valign="top"> <table width="150" border="0" cellspacing="0" cellpadding="0" bgcolor="#585858"> <tr valign="top" ><td><img width="150" src="upload/200905/11_1.jpg" alt="«Якутскгеология» — передовое предприятие геологоразведочной отрасли республики" /></td></tr> <tr><td align="left"><div style="height: 26px; overflow:hidden;"><a href="index.php?id=18" style="color:#FFFFFF; font-size:10px; font-family: Arial; text-decoration: none; margin-left: 2px; margin-right: 2px; min-widht: 150px; max-widht: 150px; height: 26px; overflow:hidden;">«Якутскгеология» — передовое предприятие геологоразведочной отрасли республики</a></div></td></tr> </table> </td><td width="160" align="center" valign="top"> <table width="150" border="0" cellspacing="0" cellpadding="0" bgcolor="#585858"> <tr valign="top" ><td><img width="150" src="upload/200905/18_1.jpg" alt="Возможности нетрадиционного использования углей дальнего востока" /></td></tr> <tr><td align="left"><div style="height: 26px; overflow:hidden;"><a href="index.php?id=34" style="color:#FFFFFF; font-size:10px; font-family: Arial; text-decoration: none; margin-left: 2px; margin-right: 2px; min-widht: 150px; max-widht: 150px; height: 26px; overflow:hidden;">Возможности нетрадиционного использования углей дальнего востока</a></div></td></tr> </table> </td><td width="160" align="center" valign="top"> <table width="150" border="0" cellspacing="0" cellpadding="0" bgcolor="#585858"> <tr valign="top" ><td><img width="150" src="upload/200905/16_1.jpg" alt="Надежное, стабильное и динамично развивающееся предприятие нефтепромыслового сервиса Республики Саха (Якутия)" /></td></tr> <tr><td align="left"><div style="height: 26px; overflow:hidden;"><a href="index.php?id=17" style="color:#FFFFFF; font-size:10px; font-family: Arial; text-decoration: none; margin-left: 2px; margin-right: 2px; min-widht: 150px; max-widht: 150px; height: 26px; overflow:hidden;">Надежное, стабильное и динамично развивающееся предприятие нефтепромыслового сервиса Республики Саха (Якутия)</a></div></td></tr> </table> </td></tr></table> </td> <td align="center" width="*"> </td> </tr> </table> <div style=" margin-top: 30px; margin-bottom: 10px; clear:both;"> <div><h1>Бизнес-предложения</h1></div> </div> <div style=" margin-top: 12px; clear:both;"> <p class="content"><div>В этом разделе мы формируем каталог из коммерческих предложений, которые появлялись на страницах нашей газеты с мая 2007 года.</div> <p> </p> <div id="card">CARD</div></p> </div> <div> <div> <div style=""><h3 style="title">Лесной Комплекс</h3></div> <div style="margin-left: 15px;"> <div style="margin-left: 15px;"><div style=""><a href="javascript:showcomp(6)">Леспром</a></div><div style=""><a href="javascript:showcomp(7)">фывфывфыв</a><div style="position: absolute; min-width: 150px; width: 150px; min-height: 150px; height: 150px; background-color: #818181; z-index: 50; margin-top: 15 px;" id="card2">asdasdasd<div align="right"><a href="javascript:closing2()">Закрыть окно</a></div></div></div></div> </div><div> <div style=""><h3 style="title">Оборудование тест</h3></div> <div style="margin-left: 15px;"> <div style="margin-left: 15px;"><div style=""><a href="javascript:showcomp(8)">123</a></div><div> <div style="">Вентиляционное2</div> <div style="margin-left: 15px;"> <div style="margin-left: 15px;"><div style=""><a href="javascript:showcomp(3)">Конверс, ООО</a></div></div> </div><div> <div style="">Сантехника</div> <div style="margin-left: 15px;"> <div style="margin-left: 15px;"></div> </div></div> </div> </div> </div> </body> </html> |
Часовой пояс GMT +3, время: 16:29. |