Link to home
Start Free TrialLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

placing a div exactly div below a td

I have an image inside a td. On mouse hovering the image, another div should show exactly below the td. It should not push the contents of the page down, instead just open it on op of the exisitng page contents. Please help me how I can position the div so that it is displayed excatly below the td. Thanks

I have attcahed the html and javascript that I have.
function HideCart(id) 
        {
            if (id.length < 1) 
            {
                return; 
            }
            document.getElementById(id).style.display = "none";
        }

        function ShowCart(id) 
        {
            
            if (id.length < 1) {
                return; 
            }
            document.getElementById(id).style.display = "block";
        }

<img src="Assets/Images/Master/shoppingcart.jpg" 
                                     style="height: 34px; width: 60px; " alt=' '  onmouseover="ShowCart('divCart')" onmouseout="HideCart('divCart');" />
                                <div    id="divCart"    style="display:none;       position:absolute;       border-style: solid; background-color: #E5E5E5; height: 4px;      padding: 5px;" class="search">
 ctent here</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Daniel Junges
Daniel Junges
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TrialUser

ASKER

junges:
I get the ele2 as null. I even tried to pass the element id to the javascript but still it shows null.

Please help
"ShowCart('tdShoppingCart','divCart');"

  function ShowCart(idTD,id)
        {

            if (id.length < 1)
            {
                return;
            }
            var objTD = document.getElementById(idTD);
            alert(objTD);
            var objCart = document.getElementById(id);
            alert(objCart);
            objCart.Style.Display = "block";
            objCart.style.top = objTD.style.top + objTD.style.height;
 
                    }
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial