简体   繁体   English

当我使用javascript点击它时如何获得相应的标签值

[英]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.

相关问题 当我使用javascript从锚标记中单击时,如何获取动态创建的标签的文本 - How do i get the text of a dynamically created label , when i click from anchor tag using javascript 在ASP.NET中使用JavaScript进行检查时,如何传递复选框的值和对应名称? - How can I pass the value and corresponding name of a checkbox when checked using javascript in ASP.NET? 单击时如何获取表格相应单元格的值 - How to get value of corresponding cell of table on click 当使用javascript单击任意按钮时如何设置标签焦点 - how to set focus for label when click the any button using javascript 如何在javascript中获取标签值 - How to get the label value in javascript 如何使用Javascript知道行号时从表行获取标签值 - How to get the label value from table row when row number is known, using Javascript 如何获取标签值作为JavaScript函数的参数? - How do I get label value as a parameter into a javascript function? 如何使用JavaScript从中继器获取选定标签的值 - How to get value of selected label from repeater using javascript 获取使用javascript计算的按钮单击事件上的gridview模板字段标签值 - Get gridview template field Label value on button click event which is calculated using javascript 使用javascript单击编辑按钮时获取GridRow值 - Get GridRow value when click edit button using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM