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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:32:23+00:00 2026-05-12T15:32:23+00:00

i have the following script and i can’t find out how to use the

  • 0

i have the following script and i can’t find out how to use the value inside car[0][‘img’] inside this $(‘#img2’).attr(‘src’,car[0][‘img’]);
im a JS noob so please explain me .. why jquery wont accept the 2d array as string value and run the function , and whats the possible solution of my problem ?

var id = 0 ;
            var car = new Array();
            car[0]['img'] = "./images/carousel_img_2.jpg";
            car[0]['title'] ="title";
            car[0]['desc'] = 'longer description goes here';
            car[0]['link'] = "http://goeshere.com";
            car[1]['img'] = "./images/carousel_img_3.jpg";
            car[1]['title'] ='title';
            car[1]['desc'] = 'longer description goes here';
            car[1]['link'] = "http://goeshere.com";
            car[2]['img'] = "./images/carousel_img_2.jpg";
            car[2]['title'] ='title';
            car[2]['desc'] = 'longer description goes here';
            car[2]['link'] = "http://goeshere.com";


            function nxt () {   
        $('#img2').fadeOut('slow', function(){

            var img = car[i]['img'] ;
            $('#img2').attr('src',img);
        });
        $('#img2').fadeIn('slow');

            }
  • 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-12T15:32:23+00:00Added an answer on May 12, 2026 at 3:32 pm

    JavaScript has separate datatypes for arrays and dictionaries (a fancy term for key/value stores, like associative arrays. Arrays are either defined through the Array() constructor (as you did) or through square brackets [], while dictionaries are defined with curly braces {}.

    An example of an array:

    var array = ['one', 'two', 'three];
    alert ( array[0] ); // "one";
    

    An example of a dictioanry:

    var dict = {
        'one': 'one one',
        'two': 'two two',
        'three': 'three three'
    }
    alert( dict.one ); // "one one"
    

    Try reworking your array definition a bit:

    var car = [
        {
            'img': './images/carousel_img_2.jpg',
            'title': 'title',
            'desc': 'longer description goes here',
            'link': 'http://goeshere.com'
        },
        {
            'img': './images/carousel_img_3.jpg',
            'title': 'title',
            'desc': 'longer description goes here',
            'link': 'http://goeshere.com'
        },
        {
            'img': './images/carousel_img_2.jpg',
            'title': 'title',
            'desc': 'longer description goes here',
            'link': 'http://goeshere.com'
        }
    ];
    alert( car[0].img ); // "./images/carousel_img_2.jpg" 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script: $ -> $('#new_event').submit -> $.post( $(this).attr('action') $(this).serialize() success: (data,
I have the following ant script that I can't seem to find a way
I have the following script: $(#border-radius).click(function(){ var value = $(#border-radius).attr(value); $(div.editable).click(function () { mySQLinsert(value,
I have the following script: $('li.cat-hider').click(function () { var activeID = $(this).attr('id'); if ($('li#'
I have the following script which works: classes = $(this).attr(class).split('_'); If $(this) 's class
I have the following bash script, we can call it script1.sh : #!/bin/bash exec
it is the problem, i can't undertand anyway. i have the following simple script
I have the following script running successfully. However if I try to use a
I have the following script: $(.Text).contents().each(function () { $(this).replaceWith($(this).text() .replace(/\[([^\]]*)\]/g, '<span class=IT_Symbol style=display:inline;border: 1px
i have the following script <select id=select1> <option value=1>1day</option> <option value=2>2day</option> <option value=3>3day</option> </select>

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.