Button with jQueryUI toggle scale effect

I have added a button to my Bootstrap4 navbar and I want to make it scale (grow and shrink) multiple times to grab attention. However, when I try to implement this using $(document).ready(function(){, I am encountering some unexpected behavior. I have included the jQueryUI CDN in my HTML and confirmed that the library is loading correctly. The issue might be related to conflicting settings within my navbar or other factors affecting the desired effect. You can view the example on jsfiddle here

$(document).ready(function(){  
      for(i=0;i<5;i++) {
       $( "#toggle" ).toggle({effect: "scale", percent: 2.0});
   $( "#toggle" ).toggle({effect: "scale", percent: 1.0});
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar fixed-top navbar-dark" style="background-color: lightslategray;">
        <a class="navbar-brand" href="#">Airforce Inventory Information Database</a>
        <button class="navbar-toggler collapsed" id="toggle" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="icon-bar top-bar"></span>
            <span class="icon-bar middle-bar"></span>
            <span class="icon-bar bottom-bar"></span>
            <span class="sr-only">Toggle navigation</span>
        </button>
</nav>

Answer №1

If you want to create a smooth animation effect, I suggest utilizing CSS classes. Below is an example demonstrating how to add a class using jQuery and then animate it repeatedly using CSS:

$(document).ready(function(){  
      $( "#toggle" ).addClass('attention');
});
.attention {
  animation: zoom-in-out 0.5s ease-in-out 5;
}

@keyframes zoom-in-out {
  0% { transform: scale(1); }
  50% { transform: scale(0.5); }
  100% { transform: scale(1); } 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar fixed-top navbar-dark" style="background-color: lightslategray;">
        <a class="navbar-brand" href="#">Airforce Inventory Information Database</a>
        <button class="navbar-toggler collapsed" id="toggle" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="icon-bar top-bar"></span>
            <span class="icon-bar middle-bar"></span>
            <span class="icon-bar bottom-bar"></span>
            <span class="sr-only">Toggle navigation</span>
        </button>
</nav>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS - Negative Margins Leading to Horizontal Scrolling Issue in Mobile Viewport

I’m working on some HTML and CSS code that looks like this: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content= ...

Error message reading "Unexpected type error in jQuery for Node. Argument 'context' required."

Currently facing an issue with deploying my node.js server online. While everything functions properly on my local machine, I encountered an error when attempting to run the server online using node: node.js:201 throw e; // process.nextTick error, ...

Ways to rearrange div elements using JavaScript

I need assistance with reordering div elements using JavaScript, as I am unsure of how to accomplish this task. Specifically, I have two divs implemented in HTML, and I would like the div with id="navigation" to appear after the div with class="row subhea ...

Challenges with jQuery selectors

Within a table, I am working with two rows identified by the ids row_26 and notificationrow_26. My goal is to highlight row_26. For this purpose, I have tried using either of the following methods: var deviceUID = 26; $("#row_" + deviceUID).effect("highl ...

Creating mobile-friendly websites for a variety of devices, including smartphones and tablets

Creating a prototype webpage for my friend, one crucial aspect is ensuring it looks good on different devices. Utilizing Bootstrap, I've implemented vertical collapsing for certain elements, but I'm struggling with how to adjust other components ...

Positioning Images in Bootstrap 4

I'm encountering an issue with Bootstrap 4. The left box isn't aligning properly with the right box. This involves both HTML and CSS. How can I go about resolving this issue? <section> <div class="container"> <div class="row"& ...

Recaptcha is functioning properly on smartphones, however, it is experiencing difficulty on computers

Hey there! I encountered an issue with my website where the recaptcha isn't working on the desktop version. It's strange because I've used the same code successfully on other sites before. I attempted to fix it by creating a new recaptcha a ...

Is there a way to verify that all of my ajax requests have finished?

I am facing a situation where I have three <select> inputs on my form, each with an option that has a zero value. If the selected value is zero, then I do not need to trigger an ajax request. However, if the option does have a value other than zero, ...

JavaScript regex problem

As I am handling a specific string: £1,134.00 (£1,360.80 inc VAT) I am currently attempting to isolate the numerical values as follows: ['1,134.00','1,360.80'] My approach involves utilizing this regex pattern in Javascript: /&bs ...

"Step-by-Step Guide to Dividing and Centering Text Sections with Dynamic

Initially, my intention is to implement the concept outlined below. The webpage has dual potential states. In the first scenario, two texts (with potentially varying lengths) are centralized together as a header. When transitioning to the second state, the ...

What is the process for installing and utilizing the custom CSSLint rules that I have developed for the command line interface?

After investing a significant amount of time into following the instructions outlined here and here for creating custom CSS linting rules using CSSLint via the CLI, I have successfully generated and tested my own set of rules. However, I am now facing the ...

Steps to create a persistent bottom modal with scrollable content

I'm currently using Bootstrap 4.6 within my Angular application. I have implemented a modal that expands to full-screen on mobile devices, and now I want to add a fixed footer with scrolling body content. I've attempted to adjust the height of t ...

guide on adding a variable to the link_to path

In my attempt to incorporate a variable into the link_to function below: <%= link_to '<button type = "button">Players</button>' .html_safe, live_players_path(:Team => @tmf) %> Whenever I click on this link, it seems to ...

What steps can be taken to avoid the appearance of the JavaScript prompt "Leaving site"?

Hi there, I'm currently trying to find a way to remove the Javascript prompt/confirm message that asks "Do you want to leave this site?" like shown in this link: The issue I am facing is that when a modal opens and the user clicks on "YES", it redire ...

Issues with single and double quotation marks in JQuery

I'm having trouble inserting a tag into the page. The tag contains both single and double quotes, so I tried storing that part in a variable named content. Can someone explain why this content variable isn't displaying onclick after the code runs ...

Dealing with Unwanted Navbar Opacity in Bootstrap 4

Currently working on a React.js project using Bootstrap 4. The issue I'm facing involves two elements - navbar and alert, both implemented from Bootstrap4. Strangely, when setting position:fixed for both elements (overriding CSS), they become semi-tra ...

Retrieve the 'computed' CSS for the entire webpage

We operate multiple websites, each referencing 3-5 CSS files. Some of these files are shared across sites while others are specific to certain pages. Our aim is to streamline the CSS structure by consolidating into fewer files without altering the end res ...

Retrieve the data value from a click event using the class identifier

The following code will display the correct class name, but not the correct data-validamount. It will only show: undefined. $(".prod_amount_add").click(function(){ var rowAmount = 0; var datavalid = $(this).attr('data-validamount'); ...

Update a portion of the list items

Here is the HTML code I am working with: <ul id="info"> <li> <span>Name:</span>Charis Spiropoulos </li> ... I need to change the content of the <li> element that is not within the span. How can I do this? Cur ...

Tips on boosting CSS specificity in Material-UI's makeStyle for styled components in order to successfully override the root style

As a newcomer in the world of React, I am attempting to utilize MUI makeStyles to customize the existing styles. However, I have encountered an issue where setting fontWeight to 'bold' does not seem to work, even when using !important. Any sugges ...