Switch to full style
JQuery Examples
Post a reply

Change and get html content of element

Mon Dec 31, 2012 12:34 pm

Add new input field at each click- dynamically in JQuery
html code
<html>
<head>
<title>Change html content of an HTML element </title>

<!--
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
 Note you can download the JQuery package instead of using Google version. --> 
<script src="jquery-1.8.3.js"></script>
<script>
$(document).ready(function(){
  $("#change1").click(function(){
     $("#div3").html($("#div3").html()+"<br/>"+$("#div2").html());
  });
  $("#change2").click(function(){
    alert("Text: " + $("#div1").text());
  });
});
</script>
</head>

<body>
<p id="test">There are three div elements </p>

<div id="div1" hidden="True">Include text to be copied to another div</div>
<div id="div2"><input type="text" value="Type Here..." /></div>
<div id="div3"></div>

<button id="change1">Add Input Field</button>
<button id="change2">Print Text</button>
</body>
</html>




Post a reply
  Related Posts  to : Change and get html content of element
 Remove HTML element or Delete its content     -  
 Change the content of select tag using JQuery     -  
 Cant change the culture or UICulture of the content page     -  
 Get the position of HTML element using JQuery     -  
 How to make html element hidden using CSS     -  
 opacity of HTML element- transparent     -  
 Get Width and Height -Inner and Outer for HTML element     -  
 removing focus border from a HTML element     -  
 checking if a HTML element is visible or hidden under JQuery     -  
 Show hint when focus on html element using JQuery     -  

Topic Tags

JQuery Content