Reputation: 1595
I would like to be able to change the text of an anchor tag based on the value of the status field. On pageload the student-status is set by a ajax request. After which I would like to check that status and see if it is active, then the hyperlink should say "DeActivate" otherwise Activate. Below I am doing the test by hardcoding the status field to Active. I would like to actually use the value that is in the with the id =student-status. Is there a way to set the status variable similar to $("#student-status).text() Example here below:
<tr>
<td>Status</td>
<td id="student-status"></td>
<c:set var ="status" scope="session" value="Active" /> <!-- want to get value from td -->
<c:choose>
<c:when test = "$(status == 'Active')">
<td class="new-student-status"><a id="activate-deactivate-student" href="#">DeActivate</a></td>
</c:when>
<c:when test = "$(status== 'Inactive')">
<td class="new-student-status"><a id="activate-deactivate-student" href="#">Activate</a></td>
</c:when>
</c:choose>
</tr>
Upvotes: 1
Views: 858
Reputation: 11579
Try this one line:
<td class="new-student-status">
<a id="activate-deactivate-student" href="#">
<c:out value="$(status == 'Active'?'DeActivate':'Activate')"/>
</a>
</td>
Upvotes: 1
Reputation: 10248
$('#student-status').html(desiredText)
will set the inner text of the #student-status
element to the value of the desiredText
variable.
Upvotes: 1