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

asked on

adding a hyperlink or href to a div

I have a div with list of shopping cart items. When users click on "add to cart" button, i would like to add a hyperlink to href to the div.
The div itself shows on mouseover a shopping cart image that I show/hide using javascript.

Now, How can I 1) dynamically add the links to the div.
2) should the links be href or asp:hyperlink.

Please help. any suggetsion would be great. thanks a ton.
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India 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

Ok , the above suggestion works great.  the code i used is as follows. only other thing is , I need like a <br /> after every link. how can i make sure the link is added in a newline each time. please help thanks

 function AddLink()
        {
            var link = document.createElement("a");
            link.setAttribute("href","Product.aspx");
            // to create a label to the link
            var lb=document.createTextNode("Product 1");
            link.appendChild(lb);
            document.getElementById("divCart").appendChild(link);
           
        }        
oh, i got it added a br. thanks a ton for your quick response.