javascript - Jquery: How to show date with textbox value? -


i newbie in jquery , wrote below code

<h1>type comment below </h1> <h2>textbox value : <label id="msg"></label>-<label id="date"></label></h2> <div style="padding:16px;">     textbox : <input type="text" value="" placeholder="type comment"></input> </div> <button id="get">get textbox value</button>  
var fulldate = new date(); $("button").click(function(){     $('#msg').html($('input:text').val());         });  

how display date when submit button press label have id="date"? when user press submit button want display

"user entered textbox value - date time" 

just use proper css selectors add messages , date. refer code below :

 $("button").click(function() {     var msg = $('input:text').val();     var fulldate = new date();      $('#msg').html(msg);     $('#date').html(tolocal(fulldate));   });   function tojsonlocal (date) {    var local = new date(date);    local.setminutes(date.getminutes() - date.gettimezoneoffset());    return local.tojson().slice(0, 10);  }   function tolocal (date) {    var local = new date(date);    local.setminutes(date.getminutes() - date.gettimezoneoffset());    return local.tojson().replace('t', ' ').slice(0, 19);  } 

note: tojsonlocal, tolocal used format date.

jsfiddle : https://jsfiddle.net/nikdtu/q8zmlebz/


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -