2

Есть такая функция

function mDown(e){
        e.target.style.position = 'absolute';
            e.target.style.width = /*ширина родителя*/;
        return false;
    }

Как через event.target обратиться к style родителя?

1 ответ 1

0

стряпал для примера

<div id="parent" style="width: 100px; height: 100px; background-color: red;">
    <div id="children"></div>
</div>

<script type="text/javascript">
function getParentCss(e)
{
    alert(e.parentNode.getAttribute('style'));
}

function setParentCss(e, newCss)
{
    e.parentNode.setAttribute('style', newCss);
}

getParentCss(document.getElementById('children'));

setParentCss(document.getElementById('children'), 'border: 1px solid #000; width: 200px; height: 200px;');
</script>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.