jquery - How to show a confirm when i click a button? -


i working asp.net mvc. trying show custom message user when clicks button.

here view :

@foreach (var item in model.ticketlist)  { var number = item.ticketid.tostring(); <tr>     <td>         @html.actionlink(number, "details", new {id=item.ticketid })     </td>     <td>title :          @html.displayfor(model => item.title)     </td>     <td> date submitted :          @html.displayfor(model => item.datecreated)     </td>     <td id="status"> ticket status :          @if (item.status == "open")          {             <span id="open">open</span>             @html.actionlink("close","close",new {id=item.ticketid})         }         @if (item.status == "closed")          {              <span id="closed">closed</span>             @html.actionlink("open","open",new {id=item.ticketid})         }     </td> </tr> <tr id="ticket-backcolor">     <td colspan="4">description :         @html.displayfor(model => item.description)     </td> </tr> 

}

the action link action controller modify value of field. works. want show confirm window in ask user if sure wants close/open ticket.

this have been trying far :

<script type="text/javascript"> function alert() {     confirm("are sure want close ticket ?"); } $(function () {     $("span[id='open']").click(alert) }); </script> 

and same open option. not work. can me ?

edit :

<script type="text/javascript"> $(document).ready(function () {     $("td[id='status']").click(function () {         return confirm('are sure want open ticket ? ');     }); }); </script>  <script type="text/javascript"> $(document).ready(function () {     document.getelementbyid("closed").click(function () {         return confirm('are sure want open ticket ? ');     }); }); </script> 

the second script not work either. script works tag. can not work 2 span tags.

use confirm

var answer = confirm("are sure?"); if (answer) {   //confirm true code }else{   //confirm false code } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -