Reputation: 16629
I have a textbox which is dynamically being added as
<div id="main"></div>
$(document).ready(function(){
var time = '2014-04-20 00:00:00';
var textbox = = '<input type="text" id="timeStatus" value='+time+'>';
$('#main').html(textbox);
});
However, the value after the space 00:00:00
is not displayed.
Upvotes: 0
Views: 929
Reputation: 700362
That's because your HTML code ends upp looking like this:
<input type="text" id="timeStatus" value=2014-04-20 00:00:00>
As you don't have any quotation marks around the value for the value
attribute, only the part before the space will be used as the value, the rest will be a separate (invalid) attribute.
You should add quotation marks so that the HTML code ends up like this:
<input type="text" id="timeStatus" value="2014-04-20 00:00:00">
That would be:
var textbox = '<input type="text" id="timeStatus" value="'+time+'">';
Upvotes: 3