我需要一个双循环,这样我就可以移动我的自定义标记,并获取属于每个下拉列表的选项,这样我就可以构建自定义对象。我的问题是,无论我做什么,它不会在IE中工作。这是我最近的尝试,它工作在Chrome,但不是IE。请帮我弄清楚如何在IE(8-11)中完成这个任务。(我目前正在使用IE9进行测试,但会在某个时候用IE8进行测试。)提前感谢
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<custom:drop id='c1' style='display:none'>
<custom:option id='d1'>t2c1</custom:option>
<custom:option id='d2'>hahahahahah</custom:option>
</custom:drop>
<custom:drop id='c2' style='display:none'>
<custom:option id='d2'>t2c2</custom:option>
</custom:drop>
<custom:drop id='c3' style='display:none'>
<custom:option id='d3'>t2c3</custom:option>
</custom:drop>
<custom:drop id='c4' style='display:none'>
<custom:option id='d4'>t2c4</custom:option>
</custom:drop>
<script>
$("custom\\:drop").each(function()
{
var s = "#"+($(this).context.id) + " custom\\:option";
alert(s);
alert($(s));
$(s).each(function(){
alert( $(this).html() );//
});
});
</script>下面是一个JSfiddle:它将在火狐和chrome中工作,但不适用于IE。
发布于 2014-01-16 01:40:02
在DOM中插入的内容确实很挑剔。您需要声明名称空间"custom“,并预先创建元素drop和option。
<html xmlns:custom="needed for custom elements">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../app/lib/jquery-1.10.2.js"></script>
</head>
<body>
<script>
// needed to make parse properly
document.createElement('drop');
document.createElement('option');
</script>
<custom:drop id='c1' style='display:none'>
<custom:option id='d1'>t2c1</custom:option>
<custom:option id='d2'>hahahahahah</custom:option>
</custom:drop>
<custom:drop id='c2' style='display:none'>
<custom:option id='d2'>t2c2</custom:option>
</custom:drop>
<custom:drop id='c3' style='display:none'>
<custom:option id='d3'>t2c3</custom:option>
</custom:drop>
<custom:drop id='c4' style='display:none'>
<custom:option id='d4'>t2c4</custom:option>
</custom:drop>
<script>
$("custom\\:drop").each(function()
{
var s = "#"+($(this).context.id) + " custom\\:option";
alert(s);
alert($(s));
$(s).each(function(){
alert( $(this).html() );//
});
});
</script>
</body>
</html>https://stackoverflow.com/questions/21151588
复制相似问题