I would like to know if it is possible to use variables in jQuery and, if so, in what way. I explain what I'm trying to do.
I have the following HTML code right now:
<html>
<head>
<title>Prueba</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="funciones.js"></script>
</head>
<body>
<div id="areas">
<ul>
<li id="programacion">Programacion</li>
<li id="sistemas">Sistemas</li>
<li id="dweb">Diseño web</li>
<li id="software">Software</li>
</ul>
</div>
<div id="contenidos">
<ul>
<li class="prog">jQuery</li>
<li class="sist">Linux</li>
<li class="web">CPanel</li>
<li class="prog">PHP</li>
<li class="soft">Photoshop</li>
<li class="prog">Bash</li>
<li class="web">WordPress</li>
<li class="sist">iOS</li>
<li class="prog">Java SE 8</li>
</ul>
</div>
</body>
And this code in jQuery:
$(document).ready(function(){
$('div#areas #programacion').mouseover(function(){
$('#contenidos li').not('.prog').css({"opacity":"0.2"});
})
.mouseout (function(){
$('#contenidos li').not('.prog').css({"opacity":"1"});
})
});
Right now, I only control that when I put the mouse on the Programming element, the li elements that are not prog vanish. Do I have to repeat the code for the elements that go with systems, dweb and software? Is there no way to do the same function for everything and depending on what you choose, vanish one or the other?
Thank you very much.