Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery .html() or .text() not working
    text
    copied!<p>I have a page in Joomla where the form loads on the fly(from the module). I have emptied the inner HTML contents of this form and inserted a content of my own to customize my forms.</p> <p>Before emptying the contents of the original form, I have placed form elements in variables of their own: </p> <pre><code>var element1 = $('#e1').val(); var element2 = $('#e2').val(); </code></pre> <p>Followed by the above lines, I have emptied the contents of the form and loaded new elements:</p> <pre><code>$('.originalform').empty(); $('.originalform').load("Location of my new file"); </code></pre> <p>And finally, I inserted the the previously stored elements in my custom elements:</p> <pre><code>$('#newDiv').text(element1); // newDiv is a div element whose innerHTML should be element1 </code></pre> <p>However, the newDiv element is not showing any value as expected.</p> <p>Has it got to do with the DOM structure since it has been modified? Please assist.</p> <p>Here you go guys. The HTML code:</p> <pre><code>&lt;script&gt; var fname=$('#firstname').val(); var lname=$('#lastname').val(); var email123=$('#email').val(); var cname=$('#cb_companyname').val(); var city=$('#cb_city').val(); var bphone=$('#cb_businessphone').val(); var hphone=$('#cb_homephone').val(); var addr=$('#cb_address').val()+"\n"+city; var postal=$('#cb_postalcode').val(); var mphone=$('#cb_mobilephone').val(); var altemail=$('#cb_alternateemail').val(); var country=$('#cb_country').val(); var name=fname+" "+lname; $('.cb_template_default').empty();//I empty a div that is within the form and load another content which is language dependant: &lt;?php if ($lang-&gt;getTag()=="en-GB") {?&gt; $('.cb_template_default').load('&lt;?php echo JURI::base(); ?&gt;templates/calderoni/edit-profile.php'); &lt;?php } else { ?&gt; $('.cb_template_default').load('&lt;?php echo JURI::base(); ?&gt;templates/calderoni/edit-profile-it.php'); //The new elements have new values inserted here. $(".newemail").text(email); $(".newname").text(name); $(".altemail").text(altemail); $(".bphone").text(bphone); $('.name').text(name); $('.altemail').text(altemail); $('.bphone').text(bphone); $('.hphone').text(hphone); $('.mphone').text(mphone); $('.cname').text(cname); $('.newaddr').text(addr); $('.postal').text(postal); $('.country').text(country); &lt;/script&gt; </code></pre>
 

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