This is my code which I am currently working on. I have to display the value passed by the user. In here I am displaying only a string which I will modify afterwards. When I click the add button I get some strange code in my alertbox
. This is the fiddle which I have made while running fiddle I am getting shell form doesn't validate. May be my code have some problem. Here is the code which I get in my alertbox.
In the console I am getting a warning:
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
Please help me sorting this out. Thanks
Dibya
Follow up: I have missed to mention. After clicking Ok
button the text disappears in the div. What causes this? How can I prevent?
you mised the function call with () that's why you get displayed the jQuery function for val.
this fiddle is working because I added ()
to the var x = $('input[name="time"]').val;
code.
It should be
var x = $('input[name="time"]').val();
$('input[name="time"]').val
refers to the val
function and alert(x)
in that case returns the string representation of val
.
In order to call the method val
and retrieve the returned value you need to use val()
.
Demo: Fiddle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.