Adding Value into an Input Field
I am working 开发者_C百科on an iPhone Web App using HTML & CSS. I have currently got the JavaScript/HTML5 Geolocation picking up my current location and showing me it on a Google Map using Lat & Long values. I also want to add these Lat & Long Values into the 'address' text field on the page so I can submit the details.
Here is the link: http://m.belfi.co.uk/form.html
When I click 'find me' I would like the lat and long to be added to the 'address' input field. Have no idea how to do this though :(
You're looking for the val
method:
$('input[name=Address]').val(function(index, oldVal) {
return oldVal + ": " + lat + ", " + lon;
});
精彩评论