我可以在函数中传递DOMelement吗? 例如......
$doc = new DOMDocument();
$doc->preserveWhiteSpace = true;
$doc->load('Sample_SGL-3-1.xsd');
$xsdstring = "Sample_SGL-3-1.xsd";
$t = new XMLREADER();
$t->open($xsdstring);
$complex=$doc->getElementsByTagName("complexType");
foreach($complex as $c)
{
$com_name=$c->getAttribute("name");
$com_min=$c->getAttribute("minOccurs");
$com_max=$c->getAttribute("maxOccurs");
if(some condition)
{
echo '<input type="button" onClick="addComplexType()">';
}
}
如何在OnClick函数中传递此$ c
答案 0 :(得分:0)
根据您在注释中的说明,您希望将PHP DOMElement传递给JavaScript函数。
简短的回答是不,你不能直接这样做。
你可以做的是为它添加一个ID属性,然后在JavaScript中通过ID获取该元素。