Serializing <input> based on class
Hello I am trying to serialize a form and submit it into my php. I have found that using the normal .serialize command turns spaces into '+' so I am trying my luck at passing a JSON.
I was wondering how you could select only the input values with a class = pass?
<input class="pass">
I am using the bottom code to turn stuff into JSON, however I am st开发者_运维百科uck on how I can select by classes?
http://jsfiddle.net/r3S5U/10/
Is there a better way to do this?
Instead of doing:
alert(JSON.stringify($('form').serializeObject()));
Just change the form selector to .pass:
alert(JSON.stringify($('.pass').serializeObject()));
Only DOM elements with the 'pass' class will be serialized now.
You can use this code:
$('.pass').serializeObject();
So, you will select only the input with class = pass.
Regards
精彩评论