I am creating a javascript function in the jsp which looks like following :-
function getBehaviorDescription() {
var behaviorId = $('#behaviorId').val();
var description;
var allocatedPoints;
<c:forEach var="behavior" items="${behaviors}">
if ("${behavior.id}" == behaviorId) {
description = "${behavior.behaviorDescription}";
allocatedPoints = "${behavior.assignPoints}";
}
</c:forEach>
$('#pointAllocated').val(allocatedPoints);
$('#descriptionButton')
.hover(
function() {
$('#desciptionTooltipText').text(description);
$('#descriptionButton').attr('style',
'position: absolute;');
$('#desciptionTooltip')
.attr('style',
'display: block; position: relative; left: 214px; height: 40px;');
});
$('#descriptionButton').mouseout(function() {
$('#descriptionButton').attr('style', 'position: initial;');
$('#desciptionTooltip').attr('style', 'display: none;');
});
}
Now when a "" double inverted comes in behaviorDescription the function breaks.
How should i escape the "" in the above code to make the correct definition of the javascript function.