2

I have a div tag and it has a link tag inside it as shown in the code. The link works only when I click on it. But I want to code in such a way that even when I click on div tag, it should go to the link. Please help as I am a beginner in javascript.

<div id="blockbuilding">
  <a id="@data.bbuildingid" href="@Url.Action("Overview","Overview", new{BuildingId=@data.buildingID})" class="buildingAnchor""> @data.buildingName </a>
</div>
Anon_y_20_raj
  • 69
  • 1
  • 9

1 Answers1

0

try this

$(document).ready(function () {

        $("#blockbuilding").click(
            function () {
                AlertSave();
            }            
        );
    });

function AlertSave() {
   alert("Alert Message OnClick");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="blockbuilding">
  <a id="@data.bbuildingid" href="@Url.Action("Overview","Overview", new{BuildingId=@data.buildingID})" class="buildingAnchor""> @data.buildingName </a>
</div>
Udhay Titus
  • 5,761
  • 4
  • 23
  • 41