开发者

jQuery data() object to JSON string

开发者 https://www.devze.com 2023-04-05 16:51 出处:网络
I\'m trying convert jQuery Data object to JSON string. I tried: $.data(plant).toJSON() JSON.stringify($.data(plant))

I'm trying convert jQuery Data object to JSON string.

I tried:

$.data(plant).toJSON()

JSON.stringify($.data(plant))

but doesn't seems to be working. It showing undefined in firebug.开发者_StackOverflow中文版(edited)

This is what I got when I log $.data(plant):

Object { residential="Condo", location="Garden", watering="Weekly"}

Can anyone tell me how to convert this jQuery data() object to JSON string?


Using JSON.stringify() should work just fine:

http://jsfiddle.net/petersendidit/gR4nQ/

0

精彩评论

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