Get and Set HTML Content - text(), html(), and val() in jquery

<input type="button" id="get_text" value="Get Text">
<input type="button" id="set_text" value="Set Text">

<input type="button" id="get_html" value="Get Html Content">
<input type="button" id="set_html" value="Set Html Content">

<input type="button" id="get_val" value="Get Textbox Value">
<input type="button" id="set_val" value="Set Textbox Value">
<p>Paragraph <b>text</b></p>
<input type="text" value="Hello jquery world" id="txt_box">
<script src=""></script>
var txt = $('p').text();

var txt = $('p').text('Follow your dreams not girls or boys :p');

var html_txt = $('p').html();

$('p').html('Paragraph <h1>text</h1>');

var txt_val = $('#txt_box').val();

$('#txt_box').val('This is very easy, you can learn it.');


Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *