<script type="text/javascript">
$(document).ready(function () {
$("#title").change(function () {
var abc = $(this).val();//previously i mentioned this in "" by mistake please update it.
alert(abc);
});
});
</script>
Datepicker is working fine for me and change function also works fine at JSfiddle
but dont know what went wrong with it in my application.
Update:
i think jquery not able to recognize "title" as valid id
Proff: i used onchange javascript function on my DropDownListFor like below
@Html.DropDownListFor(model => model.title, new[] {
new SelectListItem { Text = blueddPES.Resources.PES.Resource.mr,Value = "Mr" },
new SelectListItem { Text =blueddPES.Resources.PES.Resource.mrs,Value = "Mrs"},
new SelectListItem { Text = blueddPES.Resources.PES.Resource.miss,Value = "Miss"},
new SelectListItem { Text =blueddPES.Resources.PES.Resource.other,Value = "Other"}
}, "select", new { onChange = "copyText()" })
<script type="text/javascript">
function copyText() {
var vall = document.getElementById("title").value;
alert(vall);
}
</script>
Now when dropdownvalue changes then an alert box comes with undefined text;