[Solved] Trying to open a popup on clicking the text in mvc


You can not open popup by clicking on @html.displayfor but you can use this method for open popup.

put @Html.DisplayFor(model => item.Status) in the ‘div’or ‘span’ and give them unique id

Eaxmple:

$(document).ready(function(){
    $("#displayfor").click(function(){
       alert('message !..or use can use popup here');
    });
  
   $("#span").click(function(){
        alert('message !..or use can use popup here');
    });
});
<html>
  
  <head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

  </head>
    <div id="displayfor">
  <h5>Click on <br>
    "@Html.DisplayFor(model => item.Status)" </h5>
     </div>
  
  <br>
  <br>
  <span id="span">
   <h5>Click on  <br>
     "@Html.DisplayFor(model => item.Status)" </h5> 
  

  </span>
  
  
  </html>

solved Trying to open a popup on clicking the text in mvc