Reputation: 2228
How to insert Div text to Input field using Jquery through id???
<div id="tmstatus>bla bla</div>
<input type="hidden" name="tm_name" >
any hint???
Upvotes: 0
Views: 1054
Reputation: 2178
I guess this exactly what you need. First you take away the input element and replace it with an empty span element:
<div id="tmstatus">bla bla</div>
<span id="input_holder"></span>
Then run this jQuery code:
$(document).ready(function() {
var get_val = document.getElementById('tmstatus').innerHTML;
var element = '<input type="text" value="'+ get_val +'" name="tm_name" />';
$("#input_holder").html(element);
});
Upvotes: 0
Reputation: 40318
<div id="tmstatus>bla bla</div>
<input type="hidden" id="textBoxId" name="tm_name" >
$("#textBoxId").val($('#tmstatus').text(););
Upvotes: 2
Reputation: 133
var div_val = jQuery("#tmstatus").html();
jQuery("input[name='tm_name']").val(div_val);
Upvotes: 1
Reputation: 28763
As my consideration try this
var my_txt = $('#tmstatus').text();
$("input[name='tm_name']").val(my_txt);
Upvotes: 0