jQuery toArray() methodThe toArray() method is used to return all elements contained in the jQuery set as an array. SyntaxThis method does not accept any argument. We can understand the use of the toArray() method using an example. ExampleIn this example, we are using the toArray() method to convert the paragraphs into an array. On clicking the given button, the paragraph elements will be converted to an array, and an alert box will display that shows the innerHTML of the paragraph elements. Test it NowOutput ![]() After clicking the given button, an alert box will be displayed, as shown in the below screenshot. ![]() Similarly, three more alert boxes will be displayed by clicking the OK button in the alert box. This is because there are four paragraph elements in the program.
Next TopicjQuery removeProp() method
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week