Note that there are some explanatory texts on larger screens.

plurals
  1. POparse text in nested html tags for inline editing
    text
    copied!<p>After doing a search for my query i'm posting this question here... I'm working on inline editing script... I want to get the text between any html tag onclick on a modal box with save and cancel options so that it can be edited... These values are also sent to database using php script</p> <p>I have used jquery <code>.text</code> &amp; <code>.html</code> functions to get the value of tags of format </p> <pre><code>&lt;p&gt;Some text&lt;/p&gt; </code></pre> <p>but i'm not able to edit the value when the format is like </p> <pre><code>&lt;p&gt;This is a &lt;a href="#"&gt;Sample&lt;/a&gt; &lt;b&gt;text&lt;/b&gt;&lt;/p&gt; </code></pre> <p>My Jquery Code is:</p> <pre><code>$("#diag-wrap").hide(); $("span,p,h1,h2,h3,h4,h5,h6,li,a").click(function(){ $(this).addClass('edit'); ss = $('.edit').text(); //alert(ss); $("#diag-wrap").show(); $("#show").html('&lt;textarea id="test" cols="50" rows="15"&gt;'+ss+'&lt;/textarea&gt;'); $("#test").htmlarea(); });//click end $("#save").click(function(){ var edited = $("#test").val(); //alert(edited); $.post("bounce-back.php",{ edited:edited, old:ss}, function(data,success){ //alert(data); $('.edit').html(data); $('*').removeClass('edit'); $("#diag-wrap").hide(); }); }); $("#cancel").click(function(){ $('*').removeClass('edit'); $("#diag-wrap").hide(); }); </code></pre> <p>Code in bounce-back.php</p> <pre><code>$old_val= $_POST['old']; echo $edited_val= $_POST['edited']; $qur= mysql_query("insert into edit (old, new) values('$old_val', '$edited_val')"); </code></pre> <p>This is the HTML popup code, if it helps anyhow...</p> <p><code>&lt;div id="diag-wrap" style="position:absolute; width:100%; height:100%; background-color:#999; opacity:0.7; top:0px;"&gt; &lt;div id="wrap" style="width:500px; height:500px; margin:auto;"&gt; &lt;div id="show" style="width:419px; border:2px solid #000; background-color:#FFF;"&gt; &lt;/div&gt; &lt;button id="save"&gt;Save&lt;/button&gt;&lt;button id="cancel"&gt;Cancel&lt;/button&gt; &lt;/div&gt; &lt;/div&gt;</code></p> <p>Please help me out in finding a feasible solution...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload