Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6670781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:18:34+00:00 2026-05-26T03:18:34+00:00

is there any equivalent in moo that can replace multiple element id names i

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:18:35+00:00Added an answer on May 26, 2026 at 3:18 am

    this is somewhat wrong.

    var get_all_labels = el.getElements('label'); – returns a collection

    var 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.addClass requires 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

    $$('myelement').each(function(el) {
        var get_all_labels = el.getElements('label');
    
        // get all ids and replace them... use .get for 1.2+ or .getProperty for 1.11
        var get_label_ids = get_all_labels.map(function(label) {
            return label.getProperty("id").replace("-elem", "");
        });
    
        // add to parent element.
        el.addClass(get_label_ids.join(" "));
        console.log(el);
    });
    

    if this is not the intended behavior and you actually have a single label, then just do

    $$('myelement').each(function(el) {
        var id = el.getElement('label').get("id").replace("-elem", "")
        el.addClass(id);
        console.log(el);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any equivalent function that returns the character at position X in PHP?
Is there any equivalent 'LIKE' function(like in MySQL) for lists. for example; This is
Is there any equivalent function of memset for vectors in C++ ? (Not clear()
Is there any Ruby equivalent for Python's builtin zip function? If not, what is
Is there any function in c# equivalent to C's stdio function ungetc() ?
Is there any equivalent function on OS X to SetTimer in Windows? I'm using
Is there any equivalent to str.split in Python that also returns the delimiters? I
Is there any equivalent to this when a combo is data bound? I've been
Is there any equivalent to Collections.getOnlyElement() that works with arrays? I'm aware it's a
I have heard of .NET APIs for memcached. Is there any equivalent for EHCache?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.