<tr KMSS_IsReferRow="1" id="newoperationtype">
<td id="operationtype1">
<input type="hidden" name="operationsDraftList[!{index}].fdId">
<p class="selectimg">ppp<img src="${KMSS_Parameter_ContextPath}sys/admin/resource/images/select.png" alt="select"></p>
<sunbor:enums property="operationsDraftList[!{index}].fdOperType" bundle="sys-workflow" enumsType="sysWfMain_operations_draft" elementType="select" isEmptyAllow="true" htmlElementProperties="onchange='selectOperType(this)';"/>
</td>
</tr>
代码是别人写的,文件格式是jsp;本人并没学过jsp,但是希望点击p元素,该元素后面的那个select元素下拉菜单就能弹出下拉菜单;下面是我写的js片段:
<script src="${KMSS_Parameter_ContextPath}resource/js/jquery.js"></script>
<script>
$(function(){
alert($(".selectimg").length);//弹出1
$(".selectimg").click(function(){
alert(123)//没有弹出?????
})
})
</script>
我用alert()测试了一下,好像根本不能给p元素绑定事件,也不能给这段代码任何元素绑定事件,但是元素本身好像完全可以被遍历到,因为上面确实弹出了1;小弟不懂求大神指点,怎么才能给p绑定click事件
img 元素图片找不到,致使 p 为空,无宽度,从而无法点击
style="display:none" 你能看见你点击的是哪吗
<tr KMSS_IsReferRow="1" style="display:none" id="newoperationtype"> display:none之后这个元素不显示,所以你无法点击到。但是它确实是存在的,所以length为1
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="jquery.js"></script>
<script>
$(function(){
$(".selectimg").click(function(){
alert(123)
});
});
</script>
</head>
<body>
<tr KMSS_IsReferRow="1" style="display:none" id="newoperationtype">
<td id="operationtype1">
<input type="hidden" name="operationsDraftList[!{index}].fdId">
<p class="selectimg"><img src="../angular/weibo/img/btns.png" alt="select"></p>
<sunbor:enums property="operationsDraftList[!{index}].fdOperType" bundle="sys-workflow" enumsType="sysWfMain_operations_draft" **elementType="select"** isEmptyAllow="true" htmlElementProperties="onchange='selectOperType(this)';"/>
</td>
</tr>
</body>
</html>
这样是可以的啊 可以弹出来啊