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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:39:02+00:00 2026-06-16T14:39:02+00:00

I have the following JQuery code: var test = new Array(); $(.quiz_list_row).each(function(index){ // Gets

  • 0

I have the following JQuery code:

var test = new Array();

    $(".quiz_list_row").each(function(index){
            // Gets the data necessary to show game chosen
            $quiz_list_id = $(this).data("quizlistId");
            $quiz_level_reached = $(this).data("quizlevelReached");

                test.push($quiz_list_id,$quiz_level_reached);

            $(this).click(function(){
                alert("test: "+test);
            });

    });

The divs (using html5 to send data):

<div class="quiz_list_row" data-quizlist-id="1" data-quizlevel-reached="5">
    <div class="inline quiz_list_cell" id="quiz_list_cell_row0_id1">Quiz 1</div>
    <div class="inline quiz_list_cell" id="quiz_list_cell_row0_id2">Current level: 5</div>
</div>
<div class="quiz_list_row" data-quizlist-id="2" data-quizlevel-reached="7">
    <div class="inline quiz_list_cell" id="quiz_list_cell_row1_id1">Quiz 2</div>
    <div class="inline quiz_list_cell" id="quiz_list_cell_row1_id2">Current level: 7</div>
</div>

The problem is that I need to find out how to use the data in the array test when the user clicks on a specific row (I want to use $quiz_list_id and $quiz_level_reached).

  • 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-16T14:39:04+00:00Added an answer on June 16, 2026 at 2:39 pm

    Unless there is a specific reason you’re extracting the attributes and putting them into an array, I think you’re taking some unecessary steps to achieving what you want. Take away the complexity from this, you have access to the data attributes with the .data() method at any time you have access to the elements jQuery object, one of those times is within the click handler itself.

    var quizRows = $(".quiz_list_row");
    
    quizRows.click(function(event) {
    
        var self = $(this);
    
        //As the element clicked on has it's data attributes defined
        //You would just need to retrieve it when the element is clicked on
        var id = self.data('quizlist-id'),
            level = self.data('quizlevel-reached');
    
        console.log("id is " + id);
        console.log("level is " + level);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jQuery code: $('.save').submit(function(e){ var formElement = $(this); var data =
I have the following JQuery code: $(document).ready(function () { var $containerHeight = $(window).height(); if
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following JQuery code: <script type=text/javascript> $(document).ready(function () { var $containerHeight =
I have the following jQuery code: var isUsernameAvailable = false; function CheckUsername(uname) { $.ajax({
I have the following jquery code: $(.rotateNews).load(/load_news.php); var refreshId = setInterval(function() { $(.rotateNews).load('/load_news.php?newsID='); },
I have the following jquery - var items = new Array(); items.push({ Item1:$(myvalue).val(), Item2:$(myvalue2).val()
I have the following code, which seems to override the jQuery.error function: $.test =
I have a following javascript code: $(document).ready(function() { var paper = new Raphael(document.getElementById('canvas_container'), 1000,
I have the following code: JQuery $(document).ready(function(){ var imglink; imglink = 'url(http://poweruser.aeiou.pt/wp-content/uploads/2012/12/google.jpg)'; $('#trick_img').css('content',imglink); $(document).on(click,change,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.