请问一下我模拟点击事件 为什么第一次增加的li没反应 再次点击才弹出 aa
<!DOCTYPE html>
<html lang='zh-cmn-Hans'>
<head>
<meta charset='utf-8'>
<meta name="viewport" c>
<link rel='stylesheet' href='/weui/weui.min.css'/>
<link rel='stylesheet' href='/weui/weui.me.css'/>
<title></title>
<script type="text/javascript">
function aaa(){
document.getElementById('p1').style.display='block'
var result=submitAjaxFileds("getBrands.htm","","单位","开户银行","账号",false);
document.getElementById("p1").innerHTML=result;
}
function dd(val){
var htm= parent.document.getElementById("product_details").innerHTML
var sub = parent.document.getElementById("cancel");
var btn = document.getElementById(val.id);
btn.onclick = function() {
alert('aaa');
sub.click();
}
parent.document.getElementById('mask').style.opacity="1";
var s = "\'";
s='<li id="'+ val.id +'">' ;
k ='<li id="'+ val.id +'"><div> <div style=" float:left; width:20%;"> ' ;
k=k+ ' <img class=+ "\'"weui_media_appmsg_thumb+ "\'" src=+ "\'"./images/search.png+ "\'"/></div><div><h4 >'+document.getElementById(val.id).innerHTML +'</h4><p>' ;
k=k+ '数量<input id="sl'+ val.id +'" type="number" value="1" style=" border: none" read/>单价<input id="dj'+ val.id +'" type="number" value="3" style=" border: none" read/></p></div> </div> </li>';
if(htm.indexOf(s)>-1){ alert(document.getElementById(val.id).innerHTML +'存在');}
else
{
parent.document.getElementById("product_details").innerHTML = htm + k ; }
}
</script>
<script src='/weui/weui.me.js'></script>
</head>
<body onload()'>
<form method='post' enctype='multipart/form-data' id='form1' name ='form1' action ='addnew.htm'>
<div class='fox_group'>
<div class='weui_cells weui_cells_form' id='ipg1' name='ipg1'>
<div class='weui_cell'>
<div class='weui_cell_hd'><label class='weui_label'>单位</label></div>
<div class='weui_cell_bd weui_cell_primary'>
<input id='单位' name='单位' type='text' class='weui_input'/>
</div>
</div>
</div>
</div>
<div id='p1'>
</div>
</form>
<script src="example.js"></script>
</body>
</html>