jquery - Not able to find ("section") in ie browser -
in ie browser find("section") not working having xml content
var xmlcontent = '<?xml version="1.0" encoding="utf-8" standalone="yes"?/><section type="two_column" name="section name" id="attr_id_lines_9810"><column align="left"><label>one</label><value>test</value></column><column align="right"><label>two</label><value>222</value></column></section>'; $(xmlcontent).find("section").each(function(){console.log($(this).attr('type");});
in ie browser code not working. other browser display correct result. if 1 know solution please update.
the xml declaration not "self-closing" or paired tag. remove slash.
<?xml version="1.0" encoding="utf-8" standalone="yes"?/>
should be:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
use filter()
, not .find()
"section" not child element. have mismatched quote , missing closing parentheses (either of drive ie nuts).
$(xmlcontent).find("section").each(function(){console.log($(this).attr('type");});
should be:
$(xmlcontent).filter("section").each(function(){console.log($(this).attr('type'));});
put together, that's:
var xmlcontent = '<?xml version="1.0" encoding="utf-8" standalone="yes"?><section type="two_column" name="section name" id="cust_attr_estimate_lines_9810"><column align="left"><label>one</label><value>test</value></column><column align="right"><label>two</label><value>222</value></column></section>'; $(xmlcontent).filter("section").each(function () { console.log($(this).attr('type')); });
and can run in developer tools console in ie8 (and ff , chrome), getting expected result (two_column
) without problems.
Comments
Post a Comment