Wednesday 15 June 2011

jQuery Printing to the Screen -


Hi guys, I have a problem displaying a message on the screen using jQuery. This is the code I have:

  $ (document) .ready (function () {$ ("# signup"). Submit (function (evt) {value = $ ('# Input '). Val (); if (value == ft = value == 0 || isNa (value)) {warning ("input error, please try again");} other value = value * 2.20462262; Alert (value);});});  

I can do it with an alert but I need it to write directly on the screen in one place.

Please help :)

First of all, I believe that your < Code> #singup element is a form, since you are calling a submit event on it. A standard submitted form is a submitted event, so when you click on the submit button on that hull, they will execute whatever they set (in most cases what is in the action attribute). If you want to do something else by default, you call jQuery preventDefault () , then you, okay, stop the default job from here, whatever you want to do, you do Do more. In your case, you can add value from input field to #answer box or div or whatever.

Then, your JS will look something like this:

$ (document) .ready (function () {$ ("# signup"). Submit (function E) {e.preventDefault (); value = $ ('# field'). ('& Lt; p & gt;' + value + '& lt; / p & gt;';)}};});

And ($ "answer") in your HTML, you have a #singup form, a #field input and your requested < Code> #answer field . This is one.

Hope it helps! =)


No comments:

Post a Comment