[英]How to make jsp table row clickable to call javascript function
I have a jsp table as follows. 我有一个jsp表,如下所示。
<ul class="list-group list-group-flush" id="patternList">
<c:forEach var="pattern" items="${patterns}">
<li class="list-group-item liitem">
<strong>${pattern.id}:</strong>
<span class="pull-right" onclick="test('${pattern.name'})">${pattern.name}</span>
</li>
</c:forEach>
</ul>
I want to call following javascript function when click on table row. 我想在单击表行时调用以下javascript函数。 How can I do that. 我怎样才能做到这一点。
function test (name) {
alert(name);
}
I hope you have the jquery
added to the jsp , bind the onclick
event to the class pull-right
, 我希望您将jquery
添加到jsp中,将onclick
事件绑定到类pull-right
,
$(document).on('click', '.pull-right', function(){
alert("I am clicked and value inside me is " + this.textContent );
});
this.textContent
retrieves the value inside the span
this.textContent
检索span
内的值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.