Reputation: 3767
I have a jsp table as follows.
<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. How can I do that.
function test (name) {
alert(name);
}
Upvotes: 1
Views: 909
Reputation: 8217
I hope you have the jquery
added to the jsp , bind the onclick
event to the class 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
Upvotes: 1