Darko Darko - 1 year ago 85
jQuery Question

How to skip elements in custom vertical slider based on input value

I'm trying to skip some elements with class "skip", based on input value, but it's not working OK when input value "No" is selected.

$("input:radio[name='q1']").change(function() {
if ($(this).val() == 'Yes') {
} else {

here's the complete code in fiddle

Answer Source

here i think this is what you were trying to do:


the problems were:

  1. you were using .next() only gives the immediate sibling so use .nextAll instead

Given a jQuery object that represents a set of DOM elements, the .next() method allows us to search through the immediately following sibling of these elements in the DOM tree and construct a new jQuery object from the matching elements

  1. Your condition was backwords it should be $(this).val() == 'No'
  2. You werent skiping the hidden elements so it was still finding them... see the :not selector i added $currentItem.nextAll('.scrollStep:not(.hidden)')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download