Replace a button with text : replaceWith « jQuery « JavaScript DHTML






Replace a button with text

 


<html>
  <head>
    <script type='text/javascript' src='js/jquery-1.3.2.js'></script>
    <script type='text/javascript'>
$(document).ready(
  function() {
    $('input#id1').click(
      function($e) {
        $e.preventDefault();
        $(this).replaceWith(
          "<p>replaced</p>"
        );
      }
    );
    $('input#id2').click(
      function($e) {
        $e.preventDefault();
        $(this).replaceWith(
          "<p>replaced</p>"
        );
      }
    );
  }
);
    </script>

  </head>
  <body>
    <div>
      <input type='submit' id='id1' value='View Quote' />
    </div>
    <div>
      <input type='submit' id='id2' value='View Quote' />
    </div>
  </body>
</html>

   
  








Related examples in the same category

1.Replace text with
2.Replace with another tag
3.replaceWith(content): Replaces all matched elements with the specified HTML or DOM elements.
4.Replace all with