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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:42:20+00:00 2026-06-02T15:42:20+00:00

Well the title says it al. My javascript function build some blocks and uses

  • 0

Well the title says it al. My javascript function build some “blocks” and uses <ul> and <li> to create them. The problem is, that it removes all other <li> on the webpage.

Edit:
(well, I assume the function is causing this. And with removing I mean: they are completely gone, looking at the HTML source in the browser shows me only <ul></ul> and no <li></li> in it, they are GONE)

Giving the webpage’s <ul> and <li> a different class had no effect, it still removes the <li></li>

How can I prevent this?

The JS function (just a part of it):

//Board build up
function setBlocks() {
    bR = 0;
    counts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    var mR = 5, mC = 6;
    var tempFloor, tempRow, tempBlock;
    var floors = $('ul');
    floors.empty();
    for (var f = 0; f < 4; f++) {
        bM[f] = [];
        for (var r = 0; r < mR; r++) {
            bM[f][r] = [];
            tempRow = $('<li></li>');
        $(floors[f]).append(tempRow);
        for (var c = 0; c < mC; c++) {
            var randomNoRequired = true;
            var randomClass;
            while(randomNoRequired) {
                randomClass = Math.round(Math.random() * 10 + 0);
                if (counts[randomClass] < 6 || bR >= 66) {
                    randomNoRequired = false;
                }
            }

etc etc etc

The HTML which JS uses:

<div id="a2">
                    <ul></ul>
                    <ul></ul>
                    <ul></ul>
                    <ul></ul>
                    <a class="x"></a>
                </div>

Other HTML on webpage where the <li></li> gets removed:

<div id="scoreboard-overview">
        <ul> 
             <li>
             test
             </li>
etc etc etc

Any help is appreciated

Kind regards,
Maurice

  • 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-02T15:42:23+00:00Added an answer on June 2, 2026 at 3:42 pm

    That’s because you call

    var floors = $('ul');
    floors.empty();
    

    EDIT – to select only the ul inside <div id="a2"> use

    $('div#a2 ul');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, my problem is what the title says. I have build a small application
Well the title says it all. Is a main() function absolutely essential for a
Well the title pretty much says it all. I had: $strata = new Zend_Form_Element_Select('strata');
I think the title says it, as well...but of course some more explanation assume
Well, the title more or less says it all. I sort of understand what
Well title says all I guess. I've tried to print_r($_SERVER) but my 'post-request' I
Well, the title says it. Is it possible to create a service on Windows
Well the title kindof says what I need. Because in Javascript timeouts asynchronous I
Well as the title says i have 2 web projects that have the same
Well, the title says it all. When passing a file name to a method,

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.