Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How use each cycle for elements that was created by java script on page?
Posted
Updated 22-May-13 12:21pm
v2
Comments
Sergey Alexandrovich Kryukov 22-May-13 18:29pm    
There is no such thing as "Java script". Java is not a scripting language ;-) And JavaScript has nothing to do with Java.
—SA
Jardin1 22-May-13 18:31pm    
So, then at Jquery there is each cycle, and my element was created by Jquery. Now i cannot get access to this elements

1 solution

Get some elements:
C#
elements = $(".class_or_any_other_descriptor"); // but not id descriptor
or get some parent element, then its children:
JavaScript
parent = $("#some_descriptor"); // preferably id descriptors as it guarantees uniqueness
elements = parent.children();

Now you can iterate them:
JavaScript
$.each(children, function(index, value) {
    // do something with value:
    value.addClass("foo");
});

or
JavaScript
children.each(function() {
    $(this).addClass("foo"); // this will be a single element
});

Please see:
http://api.jquery.com/children/[^],
http://api.jquery.com/jQuery.each/[^],
http://api.jquery.com/each/[^],
http://api.jquery.com/category/selectors/[^],
http://api.jquery.com/id-selector/[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900