开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜