Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know this question has already been answered and this isn't directly regarding the question itself; more so regarding the code in the question. However, I can't post comments as I'm a brand new member, but I just thought I'd highlight a few things in your code! Mainly consistency regarding the use of jQuery.</p> <p>In the function supplied for 'submitHandler' - you empty $('#content') and then append HTML to it. This will work, but an easier method would be using the .html() function; note that this function <em>can</em> be used to return the HTML contained inside an element; but that's when no arguments are supplied. When you supply an argument, it re-writes the content of the html element. Additionally, I would most likely use the .show() method on the h1 success element; if only for code readability. </p> <p>For example:</p> <pre><code>submitHandler: function(){ $('#content').html( "&lt;p&gt;If you want to be kept in the loop...&lt;/p&gt;" + "&lt;p&gt;Or you can contact...&lt;/p&gt;"); $('h1.success_').show(); $('contactform').hide(); } </code></pre> <p>As for inputdata() - you seem to have strayed off of the jQuery ethos here a little again, I'd aim for consistency when using jQuery personally - but also as the jQuery syntax makes the traditional javascript 'document.getElemen...' object look a bit outdated/it's extra to type. <em>At its most basic</em> jQuery is essentially best viewed as a wrapper for the document object - just with added syntactical sugar. Additionally, it allows you to chain methods - so the last two expressions can essentially be "dressed up" to look as one when using jQuery.</p> <p>I'd personally use .val(), .html() and .css() functions; example:</p> <pre><code>function inputdata(){ var usr = $('#contactname').val(); var eml = $('#email').val(); var msg = $('#message').val(); $('#out').html( usr + " " + eml + msg ) .css('display', 'block'); return true; } </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