Search code examples
javascriptjqueryhtmlcanvaskineticjs

Get multiple objects from stage by class name in KineticJS


I am using using JavaScript library Kinetic.js for HTML5 canvas. Here is the method stage.get() to get objects from stage (canvas). I have assigned the id's or class names to each object

if I get the object by id var obj = stage.get('#obj_id') it works but If try to get the multiple objects by class name var objs = stage.get('.obj_class_name') it returns an empty [] object

How I can get multiple objects from stage .


Solution

  • well, you could just do .getChildren() to get all children, then iterate through the array with a loop and a condition to add a new array you created.