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

  • Home
  • SEARCH
  • 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 7944141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:28:11+00:00 2026-06-04T00:28:11+00:00

I have an script that when click a button do many things and also

  • 0

I have an script that when click a button do many things and also rename some elements, so at first I use first script and I see sometimes work, sometimes not, so change it to second script and all time worked perfectly, but there is a question. is this two scripts do same? what is the difference, rather than all of my script I just replace first one with second one.

This is first script

$(CloneTarget).find(':input[name="' + MainName + '"]').attr('name', NewSelectName);

And second one:

$(CloneTarget).find(':input').each(function () {
    if ($(this).attr('name') == MainName) {
        $(this).attr('name', NewSelectName);
    }
});

Where is the problem with first one?

Edit

Also I use this:

    $(CloneTarget).find(':input[id="' + MainId + '"]').attr('id', NewSelectId);

And every thing worked fine I am really confused here, I must mention MainName and MainId are so similar like: MainName = Model.Phones[0] and MainId = Model_Phones[0] is the difference is about . character or any other things?

  • 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-06-04T00:28:13+00:00Added an answer on June 4, 2026 at 12:28 am

    Yes, there is a difference. Your second code snippet performs a string comparison between the element’s name attribute and the value of MainName. The first one directly injects the value of MainName into an Attribute Equals selector.

    Therefore, the first snippet will fail if MainName happens to contain:

    • a single quote character ',
    • a double quote character ",
    • a character that requires escaping in selectors, such as [ or \.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some JavaScript that on button click takes a the text from the
i have a script that once clicked ( a button ) some other thing
Right now I have a script that will update once the submit button is
I have a php script that does some processing (creates remittance advice PDFs, self-billing
I hava set up AJAX script that when you click the button it calls
I have the following script that runs when a user clicks a link that
I have a script that checks something on my PC every 5 minutes and
I have a script that connects to SQL Server 2005 default instance. But I'm
I have a script that will convert a text file into a resource file,
I have a script that generates DDL scripts to define materialized views for a

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.