这让我很困惑。如何制作以下 json 函数...
$.mfjson = function() {
var mjson = { LinkToDesktopSite : [
{"section":"aboutus","name":"DemoA","mobile":"demoa.htm","desktop":"/desktop/demoa.aspx"},
{"section":"google","name":"DemoB","mobile":"demob.htm","desktop":"http://www.google.com"}
]};
}
...与我在另一个函数中的 .each 方法进行通信...
$.loopjson = function() {
$.each(mfjson().mjson.LinkToDesktopSite, function(key,value) {
var external = "www.";
if((value['mobile'] == url)) {
if((value['desktop'].indexOf(external) == -1)) {
$('.readmore').attr("href","https://www.mysite.org"+value['desktop']);
}else{
$('.readmore').attr("href",value['desktop']);
}
}
});
}
收到萤火虫控制台错误,说 .loopjson 不知道 mfjson 是什么。
感谢您的任何建议!