I have a piece of code that is creating some issues with jQuery when a "+" symbol is being passed as part of a string.
Here is an example:
var ssArr = ["First/","Second /","Third+"];
if(ssArr !== null) {
$.each(ssArr, function(ind, val){
if(val !== ''){
val = val.replace(/ /g, '').replace('/', '');
console.log(val);
$('.tstNavLi' + val).addClass('active');
}
});
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
ul li {
color: coral;
text-align: center;
font-family: "Arial", sans-serif;
font-size: 30px;
border: 3px solid coral;
margin: 20px 0
}
ul li.active {
color: blue;
border: 3px solid blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<ul>
<li class="tstNavLiFirst">First</li>
<li class="tstNavLiSecond">Second</li>
<li class="tstNavLiThird+">Third+</li>
</ul>
</body>
</html>
How can I get this to work? This is part of a cms/shopping system and the "+" symbol is used quite frequently, so I cannot change the "+" for some other symbol.
Thanks all.