Wednesday, 18 May 2016

alert and hide on click in MVC using jquery with code




HomeController 

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace ScriptLearning.Controllers
{
public class HomeController : Controller
{   
// GET: Home     
public ActionResult Index()
{
            return View();
        }
     }
}



View


@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<button id="buttonId">Click me for alert</button>
<button class="buttonClass">Click me for hide</button>
<script src="~/Scripts/Client.js"></script>





Client.js 


$(document).ready(function () {
$('#buttonId').Click(function () {
alert('Hello this is alert');   
});
   $('.buttonClass').click(function () {       
$('.buttonClass').hide();
});
});

No comments:

Post a Comment