{"options":"[{\"text\":\"王家湾\",\"value\":\"9\"},{\"text\":\"李家湾\",\"value\":\"10\"},{\"text\":\"邵家湾\",\"value\":\"13\"}]"}

json数组如上,在jQuery中这么遍历没效果:
    $.each(data,function(i,n){
    f += ''+ n.text + '';
          });
不知道是哪里写错咯。。
===============================================================

javascript就可以完成遍历。

 

HTML code
http://www.CodeHighlighter.com/

--><script type="text/javascript">
var json = {"options":"[{\"text\":\"王家湾\",\"value\":\"9\"},{\"text\":\"李家湾\",\"value\":\"10\"},{\"text\":\"邵家湾\",\"value\":\"13\"}]"}
json = eval(json.options)
for(var i=0; i<json.length; i++)
{
alert(json[i].text+" " + json[i].value)
}
</script>

 

相关文章:

  • 2022-12-23
  • 2021-11-22
  • 2021-05-02
  • 2021-07-10
  • 2021-08-25
  • 2021-12-26
  • 2021-12-26
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2021-12-26
  • 2021-12-09
  • 2021-12-25
  • 2021-12-26
  • 2021-12-26
相关资源
相似解决方案