is there any equivalent in moo that can replace multiple element id names
i have this
$$('myelement').each(function(el){
var get_all_labels = el.getElements('label');/
var get_label_id = get_all_labels.getProperty('id');
el.addClass(get_label_id);
});
but mu labels (labael_name) return additional suffix like -elem,, and I need to remove -elem,, from the new created parent class name . I tested replace but probably in the wrong spot , it returns replace is not a function , also tested custom string_replace for js but im not having any luck with it , please any hint. Thnx!
this is somewhat wrong.
var get_all_labels = el.getElements('label');– returns a collectionvar get_label_id = get_all_labels.getProperty('id');– returns an array of ids.so if you have a single label, it will go:
[labelObject#someid-elem]which will then return["someid-elem"]the problem is,
element.addClassrequires a single string, not an array of strings but you can use array.join to work around that.if you do have more than 1 label and need to add all of them as classes to the el you are looping, you can do
if this is not the intended behavior and you actually have a single label, then just do