asp.net mvc - Getting model value in jquery -
my view contains model property , submit button,
@html.labelfor(m => m.password) @html.passwordfor(m => m.password, new { id = "txtlgnpasswordreset", @class = "form-control avoid-copy-paste" }) <div class="row vert-offset-top-2 vert-offset-bottom-2"> <div class="col-md-2"> <button id="submitsave" type="submit" class="btn btncolor ladda-button">save</button> </div> </div>
on click of login button need password value in jquery, i've tried doesn't help..
$(document).ready(function() { var password = $("#txtlgnpasswordreset").html(); $("#submitsave").on("click", function() { alert(password); $.ajax({ }); }); });
thanks in advance...
you need use $.fn.val()
method instead of $.fn.html()
get current value of first element in set of matched elements or set value of every matched element.
script
var password = $("#txtlgnpasswordreset").val(); alert(password);
Comments
Post a Comment