I am trying to find the next div after an input button and toggle it.
What am I doing wrong?
JS:
$(".showNextExperience").click(function() {
$(".experience").show();
});
HTML:
Experience 1
Experience 2
Experience 3
Experience 4
Okay, this DOES NOT work ---
$(".showExperience").click(function() {
$(this).next(".experience").toggle();
});
2
When I move the input button just above the DIV it works just fine.
$(".showExperience").click(function() {
$(this).next(".experience").toggle();
});
2
Can you explain that?
解决方案
Simply:
$(".showNextExperience").click(function() {
$(this).next(".experience").toggle();
});
See: