[英]How to get corresponding label value when i click on it using javascript
How to get corresponding label value when i click on it for following jsp using javascript 当我点击它使用javascript跟踪jsp时,如何获得相应的标签值
This is my jsp page. 这是我的jsp页面。
<%
for( int i = 0; i < sam.groupName.length; i++ ) {%>
<a href='JavaScript:validation();'>
<img src='registerButton.jpg'>
<label for='groupsId' id='labeld"+i+"'><%=sam.groupName[i]%>" </label>
</a>
<% } %>
<script type="text/javascript">
function validation(){
alert("script");
}
</script>
<a href='#' onclick='validation(this)'>
(this will pass the <a>
element as the first argument to validation()
) (这会将
<a>
元素作为第一个参数传递给validation()
)
and then 然后
function validation(anchor) {
alert(anchor.getElementsByTagName("label")[0].textContent);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.