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 745487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:06:01+00:00 2026-05-14T09:06:01+00:00

i have a problem with this code: var par = []; $(‘a[name]’).each(function() { if

  • 0

i have a problem with this code:

    var par = [];
    $('a[name]').each(function() {
        if (($(this).attr('name')).indexOf("searchword") == -1) {
            par.push($(this).attr('name'));
            $('.content').empty();
            for (var i = 0; i < par.length; i++) {
                $(".content").append('<a id="par" href="#' + par[i] + '">' + par[i] + '</a><br />');
            }
        }
    });

It causes ie and firefox to popup the warning window “Stop running this script”. But it happens only when there is a very very large amount of data on page. Any ideas how to fix it?

  • 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-14T09:06:02+00:00Added an answer on May 14, 2026 at 9:06 am

    Your code should look like this:

    var par = [];
    $('a[name]').each(function() {
        if (($(this).attr('name')).indexOf("searchword") == -1) {
            par.push($(this).attr('name'));
        }
    });
    $('.content').empty();
    for (var i = 0; i < par.length; i++) {
        $(".content").append('<a id="par" href="#' + par[i] + '">' + par[i] + '</a><br />');
    }
    

    There is no reason for the second loop to be inside the first – that will just cause a lot of unneeded work.

    You can make this code a bit simpler by removing the par array and the second loop, and just creating the content inside the first loop:

    $('.content').empty();
    $('a[name]').each(function() {
        var name = $(this).attr('name');
        if (name.indexOf("searchword") == -1) {
            $(".content").append('<a id="par" href="#' + name + '">' + name + '</a><br />');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with this jQuery code: $(document).ready( function(){ alert($('#search').val()); var dummyInput =
I have weird problem with this code $('img').hover(function(){ var $cap = $(this).parent().find('.cap'); window.setTimeout(function(){$cap.stop(true,false).animate({bottom:164},500)},500); },function(){
I have this portion of code: var hasAttribute = TypeDescriptor.GetAttributes(property.DeclaringType).OfType<CrmTypeAttribute>() .Any((attr) => ((CrmTypeAttribute)attr).Name ==
I have a problem with this code: setInterval(function() { var timed = $(#chMsgCont).find(.chatMsg:last-child); var
I have a problem with JavaScript magic. When I execute this code: var page
I have problem. This is my code: var method = new DynamicMethod(dummy, null, Type.EmptyTypes);
I have problem with this piece of code: var el = $('div#editor'); el.find('*[contentEditable]').removeAttr('contentEditable'); It
I have a problem with this piece of code : var logo = document.getElementById(move_this);
I have a problem with this code, the mouseleave function is firing on IE
I have this code var file = getUrlVars()[file]; if(file){ document.getElementById('search').value = file; } function

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.