I'm playing a bit with forms in html and jQuery and I've got a problem adding a space before and after my =
sign. I'm still a beginner, and at times I dont know 100% what I'm doing, so if you've got any tips, feel free to chip in with them as well. So far this is what I've got:
<form id='target'>
<input type='text' placeholder='Name' name='name' id='name' ><br />
<input type='text' placeholder='Address1' name='address1' class='input' /><br />
<input type='text' placeholder='Address2' name='address2' class='input' /><br />
<input type='text' placeholder='Postcode' name='postcode' class='input' /><br />
<input type='text' placeholder='Country' name='country' class='input' /><br />
<input class='input' type='submit' name='submit' value='Submit' />
</form>
and my jQuery:
$(document).ready(function() {
$('#target').submit(function(event){
event.preventDefault();
var name = $("input[name='name']").serialize();
var address1 = $("input[name='address1']").serialize();
var address2 = $("input[name='address2']").serialize();
var postcode = $("input[name='postcode']").serialize();
var country = $("input[name='country']").serialize();
$('#cont8').html("<div class='formreturn'>"+ name + "<br />"+ address1 + "<br />" + address2 + "<br />"+ postcode + "<br />"+ country +"</div>");
});
});
This return
s:
Name=MyName <br />
Address1=MyStreet1 <br />
Address2=MyStreet2 <br />
Postcode=MyPostcode <br />
Country=MyCountry
Which is fine (although the code might be a bit messy?!)
But I want to add a space on either side of the =
sign. How do I do that?
Any help is really appreciated!