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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:01:43+00:00 2026-05-28T06:01:43+00:00

I have a jquery loop where it displays buttons A – Z but what

  • 0

I have a jquery loop where it displays buttons A – Z but what it does is display 7 buttons in a row. So it should look like this below:

    A B C D E F G
    H I J K L M N
    O P Q R S T U
    V W X Y Z

But the problem is that this loop is causing the last buttons in each row to be missing. So buttons G, N and U are missing. I want to know why are they missing and how can I fix the code below to show these buttons as well as the rest of the buttons.

    var i = 1;

    $('#optionAndAnswer .answers').each(function() {
        var $this = $(this);
        var $newBtn = '';
        if($this.is(':visible')){
            $newBtn = $("<input class='answerBtnsRow answers' type='button' style='display: inline-block;' onclick='btnclick(this);' />").attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class'));
        }else{
            $newBtn = $("<input class='answerBtnsRow answers' type='button' style='display: none;' onclick='btnclick(this);' />").attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class'));
        }

                    if(i % 7 == 0){
              $answer.append($newBtn+"<tr></tr>");
            }
            else
             $answer.append($newBtn);                 
            i = i+1;
        });




PHP CODE:


<?php
    $a = range("A","Z");
?>

    <table>
        <tr>

    <?php
        $i = 1;
        foreach($a as $key => $val){
            if($i%7 == 1) echo"<tr><td>";
            echo"<input type=\"button\" onclick=\"btnclick(this);\" value=\"$val\" id=\"answer".$val."\" name=\"answer".$val."Name\" class=\"answerBtns answers answerBtnsOff\" style=\"display: inline;\">";       
            if($i%7 == 0) echo"</td></tr>";
            $i++;
        }
    ?>
        </tr>
    </table>
  • 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-28T06:01:43+00:00Added an answer on May 28, 2026 at 6:01 am

    [ignore]

    $newBtn+"<tr></tr>"
    That’s a jQuery instance + String.
    I think that’s where the problem lies.
    Try keeping newBtn as a string all through until a final $answer.append($(newBtn));.

    [/ignore]

    I just tried building a single string and it turns out to be cumbersome.

    The following solution is closer to your original intent, but avoids the trap of trying to append the invalid HTML fragment "</tr><tr>":

    var $this, i=0, $row, $cell;
    $('#optionAndAnswer .answers').each(function() {
        $this = $(this);
        if(i%7 == 0) {
            $row = $('<tr />').appendTo($answer);
            $cell = $('<td />').appendTo($row);
        }
        $("<input class='answerBtnsRow answers' type='button' style='display:%s;' onclick='btnclick(this);' />".replace('%s',$this.is(':visible')?'inline-block':'none')).attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class')).appendTo($cell);
        i++;
    });
    

    Tested only for synatax errors

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have this line of code in an for loop: echo '<toggle_me style=display: none><img
I have jquery validation code which is working fine in ff but the same
I keep getting this error all over the place where I only have jquery
I'm struggling to find the right terminology here, but if you have jQuery object...
does jquery have any plugin that prevents entering any input to a textbox that
I have a small problem with my jQuery image rotator. Basically, my rotator should
I'm using current jQuery plugin (address) and I have this code (I'm using SEO
Please see the below code: I am have a table row defined using asp.net

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.