jQuery even() methodThe even() method in jQuery is used to select the elements with even index numbers (such as 2, 4, 6, etc.). The index starts with 0. It works similar to the odd() method, but it selects even numbers. The even() method returns the even indexed elements from the set of selected elements. This method is used without any arguments. SyntaxIt does not accept any parameter. Let's see some of the illustrations to understand the working of the even() method. Example1It is a simple example of using the even() method. In this example, we are using the even() method to select the list items with an even index. There are ten list items starting from 0 to 9. The index starts from 0. So, on clicking the given button, the method will select the list elements that appeared on even index values. We have to click the given button to see the effect. Test it NowOutput After the execution of the above code, the output will be - After clicking the given button, the output will be - Example2It is another example of using the even() method. In this example, there are some checkboxes. We are using the even() method to select the even checkboxes. Here, there are six checkboxes starting from the zero indexes. The index starts from 0. So, on clicking the given button, the method will select the checkboxes that appeared on even index values. We have to click the given button to see the effect. Test it NowOutput After the execution of the above code, the output will be - After clicking the given button, the output will be -
Next TopicjQuery :file selector
|