'Click and Change Event based on element in one function
Hello is there any way to fire click or change event based on next div content.
If dropdown -> change event if lable -> click event
Here is my code what i have done.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Loop Through Elements with the Same Class</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
var first = $('.parent .sub').hide();
first.first().slideDown();
first.on("click","change",function() {
$(this).nextAll('.parent .match').eq(0).slideDown();
});
});
</script>
</head>
<body>
<div class="parent">
<div class="sub match">
<select>
<option>1</option>
<option>2</option>
</select>
</div>
<div class="sub">
<select>
<option>3</option>
<option>4</option>
</select>
</div>
<div class="sub match">
<lable>5</lable>
<lable>6</lable>
</div>
<div class="sub">
<select>
<option>7</option>
<option>8</option>
</select>
</div>
<div class="sub match">
<select>
<option>9</option>
<option>10</option>
</select>
</div>
<div class="sub match">
<select>
<option>11</option>
<option>12</option>
</select>
</div>
</div>
</body>
</html>
Please help me out with this
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
