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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:01:49+00:00 2026-06-10T22:01:49+00:00

I am wanting to append some HTML content from a variable for smaller screen

  • 0

I am wanting to append some HTML content from a variable for smaller screen sizes.However when I resize the browser the content appends(as it should) but if I keep moving the window it continues to append multiple copies of the HTML.

How could I prevent it from doing this?

This what I am doing:

function adjustStyle(width) {
      width = parseInt(width);
        if (width < 700) {
            $('ul.nav li.top ul.submenu').removeAttr("style");
            $('body').append(str);  // this is when I am having the problem appending

        } else if (width >= 700) {
            $('ul.nav').removeAttr("style");
            $('.form-wrapper').removeAttr("style");
            var toggle = function(direction, display) {
            return function() {
              var self = this;
              var ul = $('ul.submenu', this);
              if( ul.css('display') === display && !self['block' + direction] ) {
                self['block' + direction] = true;
                ul['slide' + direction]('fast', function() {
                  self['block' + direction] = false;
                });
              }
            };
          };
          $('ul.nav li.top').hover(toggle('Down', 'none'), toggle('Up', 'block'));
          $('ul.nav li.top ul.submenu').hide();
          $('#gallery').remove();
        } else {

        }
    }
$(function() {
    adjustStyle($(this).width());
    $(window).resize(function() {
        adjustStyle($(this).width());
    });
});
  • 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-10T22:01:51+00:00Added an answer on June 10, 2026 at 10:01 pm

    You need to debounce the resize event such that it fires only when resize is complete.

    This is required because –

    • In IE, Safari, and Chrome many resize events fire as long as the user continues resizing the window.
    • Opera uses as many resize events, but fires them all at the end of the resizing.
    • Although, Firefox fires one resize event at the end of the resizing.

    Following is a snippet from my answer to this question.

    var resizeTimer = null;    
    
    $(window).resize(function(){
    
       clearTimeout(resizeTimer); //ignore previous trigger
    
       resizeTimer= setTimeout(function(){ //wait to execute handler again
         //execute actual handler here
       }, 10);
    });
    

    In addition to this, I suggest you have a placeholder for adding your content –

    $('body #appendTarget').html(str); //Since .append() will anyways append multiple times
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble with Jquery append feature. I am wanting to have
I am wanting to run a jquery.append function on some divs. Basically, I am
I'm wanting to add an element created using an Html helper to the screen
I need to append some hexadecimal characters to my string. I'm trying this: content
Wanting to give byobu a looksee as a screen 'update' of sorts. I start
I'm wanting to extract a zip file loaded with images into memory in some
I'm wanting to use a php variable as the destination email for Amazon SES
I am wanting to print the running time of my functions. For some reason
I am basically wanting to fetch an IDIctionary from a place which is global
I have some drag and drop functionality on my website, I am wanting 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.