jQuery Page Widget How to - Change the text to heading








Question

We would like to know how to change the text to heading.

Answer


<!--from   w w  w  .j  a  v  a2s .  c  o  m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $('form').contents().filter(function(){
       return this.nodeType == 3 && $.trim(this.nodeValue).length;
    }).wrap('<h1/>');
});
</script>
</head>
<body>
  <form name="myform">
    Text #1 
    <input type="text" /> 
    <br />
    Text #2 
    <input type="text" />
    <p>test</p>
    
  </form>
</body>
</html>

The code above is rendered as follows: