Remove elements by class name with dojo

How can I remove all elements found by a class name. I want to do this using the dojo framework.

Answers:

Answer

Try the below code.

<div id="list">
    <div class="odd">One</div>
    <div class="even">Two</div>
    <div class="odd">Three</div>
    <div class="even">Four</div>
    <div class="odd">Five</div>
    <div class="even">Six</div>
</div>



dojo.query(".odd").forEach(function(node, index, nodelist){
    // for each node in the array returned by dojo.query,
    // execute the following code
    dojo.remove(node);
});

Referred below links :

https://dojotoolkit.org/reference-guide/1.7/dojo/destroy.html

http://dojotoolkit.org/documentation/tutorials/1.6/using_query/

Thanks,

Siva

Answer

Try with this:

dojo.query(".class_name").forEach(dojo.destroy);

DEMO

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.