title: replace any html tag to input using javascript onclick
body: <p>I'm trying to replace html tags to input with javascript
  If the tag is pressed it turns to input</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;a href="#"&gt;text&lt;/a&gt; 
  </code></pre>
  
  <p>replace to:</p>
  
  <pre><code>&lt;input value="text" /&gt;
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>&lt;h2 href="#"&gt;text&lt;/h2&gt; 
  </code></pre>
  
  <p>replace to:</p>
  
  <pre><code>&lt;input value="text" /&gt;
  </code></pre>
  
  <p>This is the code :
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/**
    We're defining the event on the `body` element, 
    because we know the `body` is not going away.
    Second argument makes sure the callback only fires when 
    the `click` event happens only on elements marked as `data-editable`
  */
  $('body').on('click', '[data-editable]', function(){
    
    var $el = $(this);
                
    var $input = $('&lt;input/&gt;').val( $el.text() );
    $el.replaceWith( $input );
    
    var save = function(){
      var $p = $('&lt;p data-editable /&gt;').text( $input.val() );
      $input.replaceWith( $p );
    };
    
    /**
      We're defining the callback with `one`, because we know that
      the element will be gone just after that, and we don't want 
      any callbacks leftovers take memory. 
      Next time `p` turns into `input` this single callback 
      will be applied again.
    */
    $input.one('blur', save).focus();
    
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;p data-editable&gt;First Element&lt;/p&gt;
    
   &lt;a data-editable class="navbar-brand" href="#page-top"&gt;Second Element&lt;/a&gt;
  &lt;p&gt;Not editable&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The problem is: my classes deleted and also not be a tag that has been created 'p' and not "a" or "h2" or whatever</p>