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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:06:43+00:00 2026-05-24T23:06:43+00:00

Can i use native javascript for loop within jquery code? I have a construct

  • 0

Can i use native javascript for loop within jquery code? I have a construct in which $.each does not seem feasible. How can I loop in this situation?

the code inside the for loop is not working. any advice would be appreciated.

if (item.relate){
    $(prodHeading).append(item.name);
    if (item.image) {$(prodContent).append(item.image);}
    if (item.description) {
        $(prodContentText).append(item.description); 
        $(prodContent).append(prodContentText);
    }
    $(prodBox).append(prodHeading);
    $(prodBox).append(prodContent);

    //going to look for other attached items

    for (j=0; j<10; j++){
        var prodBox = $(document.createElement('div')).attr('class','productBox');
        var prodHeading = $(document.createElement('div')).attr('class','productBoxHeading');
        var prodContent = $(document.createElement('div')).attr('class','productBoxContent');
        var prodContentText = $(document.createElement('div')).attr('class','text');

        if ('item.image'+j) {$(prodContent).append(item.image);}
        if ('item.description'+j) {
            $(prodContentText).append(item.description); 
            $(prodContent).append(prodContentText);
        }
        $(prodBox).append(prodHeading); 
        $(prodBox).append(prodContent);
    }
}
  • 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-24T23:06:44+00:00Added an answer on May 24, 2026 at 11:06 pm

    First,

    for (j=0; j<10; j++){
    

    should be using a declared variable:

    for (var j=0; j<10; j++){
    

    Second,

    if ('item.image'+j) {
    

    does not make much sense. Every such string will pass an if condition. If you are looking whether an element exists, use:

    if ($('item.image'+j).length) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to find an easy to use, .net native way to get
In C++/CLI , you can use native types in a managed class by it
I am using both javascript and jquery code on the same html page. For
I have this code that loads an xml file using javascript: function getXmlDocument(sFile) {
First up, JavaScript is definitely not my native tongue. Nevertheless, I've been tasked with
Can someone please explain what does the following line of code exactly do? If
Does PhoneGap just use UIWebVIew or is it doing something more then that? Can
I would like to create a Javascript class that I can use like so:
You can use more than one css class in an HTML tag in current
You can use a standard dot notation or a method call in Objective-C to

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.