Please check the code bellow. I want to grab on click basis input field value. for example when click on save button it will grab its input value like "john" & "pohn" and display to console.log() from variable named CategoryName. Code bellow is failed to grab value properly. thanks in advance
Html:
<input class="form-control" id="editName" value="john"/>
<button type="button" class="btn btn-default Save" name-value="05" id-value="01">Save</button>
<input class="form-control" id="editName" value="pohn"/>
<button type="button" class="btn btn-default Save" name-value="06" id-value="02">Save</button>
jquery:
<script>
$(document).ready(function () {
$(".Save").on("click", function () {
var id = $(this).attr("id-value");
var CategoryName = $(this).attr("id").valueOf();
console.log(CategoryName);
});
});
</script>