I am new to jquery and programming.
Instead of using the #id for the addClass in jquery, can we send the variable as the id.
Below is the proper code using #id.
what i been thinking is using variable such as x
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
.red{
background-color:red;
}
</style>
<script>
var x=1;
$('#1').addClass('red');
</script>
</head>
<body>
<section id=1>1</section>
<section id="2" class="sec">2</section>
<section id="3" class="sec">3</section>
<section id="4" class="sec">4</section>
<section id="5" class="sec">5</section>
</body>
</html>
is there any way to send variable directly as the id.something like this
var x=1;
$(x).addClass('red');