I'm trying to create a simple button using jquery. When the user clicks a button, the value of 'timestart' is copied into 'timeend'.
<input id="timestart" name="timestart" value="" />
<!-- need button here: Click here to copy/paste value into timeend field -->
<input id="timeend" name="timeend" value="" />
Any help appreciated, thanks!
Put a button in there, give it an ID or some other defining characteristic, and simply set the value of timeend
when it's clicked. This example assumes some element with an ID of "yourButton":
$("#yourButton").on("click", function () {
$("#timeend").val($("#timestart").val());
});
References:
This is very simple stuff. I would suggest spending some time reading through the jQuery docs to get an idea of the methods available to you.
do it like this
$('#btnSubmit').click(function(){
$('#timeend').val($('#timestart').val());
});
HTML
<input id="timestart" name="timestart" value="" />
<button id='copy'>Copy</button>
<input id="timeend" name="timeend" value="" />
jQuery
$(function(){
$("#copy").on("click",function(){
$("#timeend").val($("#timestart").val())
})
})
Try this:
$('.button').on('click', function(){
var val = $('#timestart').val();
$('input#timeend').val(val);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.