Помогите закрыть модальное окно
Прошу помощи закрыть модальное окно.
Сейчас закрывается только при клике на пустую часть <u id="myStar" style="cursor: pointer">Звёздочка, по ней кликать</u> <div id="myDIV" style="background: #eee; width: 234px; height: 89px; position: absolute; display: none"> содержимое</div> <script> function clickDoc (ev) { clearTimeout (TMR); var e = window.event || ev, o = e.srcElement || e.target, star = document.getElementById ('myStar') while (o.parentNode) if (o.id == 'myDIV') break; else o = o.parentNode; if (o.id != 'myDIV') star.onclick = clickStar, star.style.cursor = 'pointer', document.getElementById ('myDIV').style.display = 'none', document.onclick = null; } function clickStar () { TMR = setTimeout ('document.onclick = clickDoc', 0); var star = document.getElementById ('myStar'), l = t = 0; star.onclick = null, star.style.cursor = 'default'; while (star.offsetParent) t += star.offsetTop, l += star.offsetLeft, star = star.offsetParent; with (document.getElementById ('myDIV').style) left = (l + 13) + 'px', top = (t + document.getElementById ('myStar').offsetHeight + 12) + 'px', display = 'block'; } document.getElementById ('myStar').onclick = clickStar; </script> |
есть решение, может кому-то пригодится:
строки 8-10 переписать if (o.id != 'myClose') while (o.parentNode) if (o.id == 'myDIV') break; else o = o.parentNode; if (o.id == 'myClose' || o.id != 'myDIV') <span id="myClose" style="text-decoration: underline; cursor: pointer">X</span> |
Часовой пояс GMT +3, время: 19:07. |