Search code examples
htmlhyperlinkoverlapping

Two links overlapping


ive got a problem with HTML.

Ive got a linking div that contains a linking image. When I click on the image, i get both (image's and div's) links opening, whereas I'd like to open just the image one.

How can I make it work? I need that when I click on the entire div, except for the image area, I get to the div's link, otherwise on the image's one.

Thanks in advance, Alessio


Solution

  • You can do it this way:-

    function func1()
    {
    window.location.href="http://www.google.com";
    
    }
    
    function func2()
    {
    window.location.href="http://www.yahoo.com";
    
    }
    

    HTML CODE

     <div id="divid" >
     <div onclick="func1()"> Some text to fill the space... blah blah blah</span></div>
    <img id="imgid" onclick="func2()" src="SOMEIMAGE" />
    </div>