我该如何在jQuery中遍历PHP数组?我有一个名为
如果我提供 <\p>
我该如何用jQuery编写代码来获取$view['Attribute']['type']的值?elem['Attribute']['type']不能起作用,对吧? 修改2 elem['Attribute']['type'] 确实有效。
$viewfields
的PHP数组。我该如何使用jQuery遍历该数组的每个元素?
编辑1
<?php foreach ($viewfields as $view): ?>
if(<?=$view['Attribute']['type'];?>=='text'||<?=$view['Attribute']['type'];?>=='number')
{
$("<input id=input<?=$view['Attribute']['sequence_no'];?> type= 'text' style= 'width:<?=$view['Attribute']['size'];?>px' data-attr=<?=$view['Attribute']['type'];?> ></input><br>").appendTo("#fb_contentarea_col1down21 #<?=$view['Attribute']['sequence_no'];?>");
}
如果我提供 <\p>
$.each(arrayfromPHP,function(i,elem){
}
我该如何用jQuery编写代码来获取$view['Attribute']['type']的值?elem['Attribute']['type']不能起作用,对吧? 修改2 elem['Attribute']['type'] 确实有效。
print_r
返回的那样?只需粘贴print_r($viewFields)
的输出即可。 - Ionuț G. StanjQuery.each
的一些文档:http://docs.jquery.com/Utilities/jQuery.each - Ionuț G. Stan