You need to use .find()to get the element inside the clicked element. In addition, the value you need to display is larger than the value already present in it.
$("li").on("click", function() {
$(this).find('.top-right').html(function(){
return +$(this).html() + 1
});
});
$("li").on("click", function() {
$(this).find('.top-right').html(function(){
return +$(this).html() + 1
});
});
.list li {
list-style-type: none;
display: inline-block;
background-color: white;
margin-right: 7px;
}
.list {
margin: 5px;
}
.list li a {
text-decoration: none;
color: black;
padding: 2px;
}
.list li a:hover,
.list li a:hover {
color: black;
}
<!DOCTYPE html>
<html>
<head>
<title>Exam</title>
</head>
<body>
<div class="list">
<ul>
<li><a href="#">NAME <span class="line"></span> AWONUSI OLAJIDE</a><span class="top-right"></span></li>
<li><a href="#">NAME <span class="line"></span> ADEGBULUGBE TIMILEHIN</a><span class="top-right"></span></li>
<li><a href="#">NAME <span class="line"></span> OLUOLU ADEDEJI</a><span class="top-right">9999</span></li>
<li><a href="#">NAME <span class="line"></span> OYAJE JOSHUA</a><span class="top-right">9999</span></li>
<li><a href="#">NAME <span class="line"></span> ALABI OJO ADE</a><span class="top-right">9999</span></li>
<li><a href="#">NAME <span class="line"></span> AKILO AWANI</a><span class="top-right">9999</span></li>
<li><a href="#">NAME <span class="line"></span> AYUBA DEJIMARK</a><span class="top-right">9999</span></li>
</ul>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
</body>
</html>
Run codeHide result source
share