0

I have a div with fixed position inside another div that spans down past the page fold. Now, there are other elements withing that parent div as well, mostly at the top of the page. I would like to hide the child with fixed position if it happens to be over another element within this parent, for example if a user resizes the window. How can I do that with jQuery?

Here's what I've got so far:

JS

$(function(){
    function floatingDiv(){
        var m = $('#parentDiv'), offset = m.offset(), posL = Math.floor(offset.left - 15);
        $('#divFloat').remove();
        m.append(\"<div id='divFloat' style='position:fixed;left:\"+ posL +\"px; bottom:55px; border:0'><a href='/' style='width:168px;height:43px; background: url(/i/free3day.png) no-repeat center center;position:fixed; border:0; left:\"+ posL +\"px;bottom:55px'></a></div>\");
    }

    floatingDiv();

    $(window).resize(function(){
        floatingDiv();
    });
});

HTML

<div id="parentDiv">
    <a href="#">SOME LINK</a>
    <div>some content</div>
</div>
4

0 回答 0