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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:29:28+00:00 2026-06-04T10:29:28+00:00

I have this code: $(window).resize(function() { if($(window).height() < 768) { $(‘div#navigation ul li br’).remove()

  • 0

I have this code:

$(window).resize(function() {
        if($(window).height() < 768) {
            $('div#navigation ul li br').remove()
        } else {
}
    })

Is it possible to reverse the remove event on else? I need to have those
tags in the same place as before the action.

  • 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-04T10:29:29+00:00Added an answer on June 4, 2026 at 10:29 am
    $(window).resize(function() {
      $('div#navigation ul li br').toggle( $(this).height() >= 768 );
    });
    

    .toggle() takes a Boolean parameter that defines whether the selected elements should be hidden (jQuery uses CSS display: none;) or shown.

    In this case, window height is used to calculate the Boolean.


    Premature optimization: If the above is sluggish for some reason, you could optimize it by selecting the breaks beforehand and remembering state to decide whether there is anything to do in the first place:

    $(window).resize( (function () {
      var $window = $(window),
          $navigationBreaks = $('div#navigation ul li br'),
          prevState = isLargeWindow();
    
      function isLargeWindow() {
        return $window.height() >= 768;
      }
    
      return function () {
        var newState = isLargeWindow();
    
        if (newState == prevState) return;
    
        $navigationBreaks.toggle(newState);
        prevState = newState;
      };
    })() );
    

    This is a lot more code, a lot more complex and potentially a few milliseconds faster than the one-liner approach. Take it with a grain of salt.

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

Sidebar

Related Questions

I have code like this: $(document).ready(function() { $(div #covert, div #coverb).height($(window).height() / 2 +
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have this code: public class Window extends JFrame { public Window(){ ... JButton
I have this code which draws a Window and NSView, and have set up
I have this code... <style type=text/css> #container { width: 200px; height: 200px; background-color: #567;
I have a window in which I want to add/remove component and resize the
I have a jQuery flot chart with this code: $(table.statics).each(function() { var colors =
I have a small function that runs on load and window resize.. but the
Conditions: Windows 98 SE WMI not available I have code that looks like this,

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.