What could be causing jQuery to successfully animate the size of my div element but not the color of my text?

My jQuery code successfully animates the height and width of divs, but it doesn't seem to be working for the text color within those divs. I'm not sure what I'm missing here. Below is the full code snippet, with lines 9 and 12 being the ones that are causing issues.

Code Snippet:

$(document).ready(function() {
  $(".postit_family").hover(function() {
    $(this).animate({
      height: "138",
      width: "150",
      left: "-=10",
      top: "-=9",
      'line-height': "132px"
    }, "fast");
    $("span").animate({
      color: "red"
    }, "fast");
  }, function() {
    $(this).animate({
      height: "120",
      width: "130",
      left: "+=10",
      top: "+=9",
      'line-height': "118px"
    }, "fast");
    $("span").animate({
      color: "black"
    }, "fast");
  });
});
a:hover {
  text-decoration: none !important;
}

#container {
  width: 780px;
  height: 673px;
  background-image: url("https://epwork.ep.corp/wg/Residuals/Images1/iMac.jpg");
  position: relative;
}

.postit_family {
  width: 130px;
  height: 120px;
  text-align: center;
  line-height: 118px;
  position: absolute;
}

.postit_family span {
  display: inline-block;
  vertical-align: middle;
  line-height: normal;
  font-family: Raleway;
  text-align: center;
  color: #67768A;
  width: 90px;
  font-size: 18px;
}
/* Additional CSS styles for postits go here */

<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet'>

// JQuery and jQuery UI script sources
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet'>
<script src="https://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js">
</script>

Answer №1

The main issue with your code not functioning as intended lies in the specific line (jQuery UI link):

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>

To rectify this, simply update it to the following (replace http with https) and everything should work smoothly:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js">

The reason for the previous malfunction was due to Mixed Content, where the browser opted to disregard it because it was loaded from an insecure origin http, while other resources are fetched via https.

You can easily confirm this by checking your console. Below is a snapshot of what my console displays: https://i.sstatic.net/YtHxh.jpg

Snippet:

/* --- JavaScript --- */
$(document).ready(function() {
  $(".postit_family").hover(function() {
    $(this).animate({
      height: "138",
      width: "150",
      left: "-=10",
      top: "-=9",
      'line-height': "132px"
    }, "fast");
    $("span").animate({
      color: "red"
    }, "fast");
  }, function() {
    $(this).animate({
      height: "120",
      width: "130",
      left: "+=10",
      top: "+=9",
      'line-height': "118px"
    }, "fast");
    $("span").animate({
      color: "black"
    }, "fast");
  });
});
/* --- CSS --- */
a:hover {
  text-decoration: none !important;
}

#container {
  width: 780px;
  height: 673px;
  background-image: url("https://epwork.ep.corp/wg/Residuals/Images1/iMac.jpg");
  position: relative;
}

.postit_family {
  width: 130px;
  height: 120px;
  text-align: center;
  line-height: 118px;
  position: absolute;
}
...
... (CSS code continues)
...
<!--- HTML --->
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet'>
<script src="https://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>

<div id="container">
  <a href="#">
    <div id="postit_1" class="postit_family"><span>Start Card</span></div>
  </a>
  <a href="#">
    <div id="postit_2" class="postit_family"><span>Invoice & Time Card Entry</span></div>
  </a>
  <a href="#">
    <div id="postit_3" class="postit_family"><span>Smart Products</span></div>
  </a>
  <a href="#">
    <div id="postit_4" class="postit_family"><span>Reports</span></div>
  </a>
  <a href="#">
    <div id="postit_5" class="postit_family"><span>Paycodes</span></div>
  </a>
  <a href="#">
    <div id="postit_6" class="postit_family"><span>System Guides</span></div>
  </a>
  <a href="#">
    <div id="postit_7" class="postit_family"><span>Occ Codes</span></div>
  </a>
  <a href="#">
    <div id="postit_8" class="postit_family"><span>Marcs</span></div>
  </a>

</div>

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

Background misalignment issue in Internet Explorer 6

My browser is IE6. [UPDATE: You can view the template live at this link: ] I have a template that utilizes 3 <a></a> tags to change the background position and create a button effect. This is how it appears in all browsers https://i.sstatic ...

Tips for retrieving the user-input value from an HTML text field

Exploring the world of JS, I set out to create a basic calculator after just one week of lessons. However, I hit a roadblock when trying to extract user-input values from my HTML text fields. Here's a snippet of my html: <div class="conta ...

Can you identify the issue with the phase control in my sine wave program?

I have recently developed an interactive sine wave drawing web application. Below is the code snippet for reference: const canvas = document.getElementById("canvas"), amplitude_slider = document.getElementById("amplitude_control"), wavelength_slider ...

Alignment of inputs remains stubbornly off-center despite floating left

My main goal is to have all my inputs aligned to the left for a clean and organized look, similar to the image provided below: https://i.sstatic.net/5c0mX.png Despite my efforts to float the inputs and paragraphs to the left, I am facing an issue where t ...

Is there a way to execute a condition in a Vue component before rendering the HTML in the template?

Here is an example of my Vue component: <template> <div id="modal-transaction" class="modal fade" tabindex="-1" role="dialog"> ... <div class="modal-header"> <h4 class="modal ...

Enhancing TypeScript - Managing Variables within Namespace/Scope

Why is the console.log inside the function correctly logging the object, but after the function returns it logs undefined, failing to update the variable? In addition, when using this within testNameSpace, it returns window. Why is that? namespace testNa ...

Issue with updating patch version using NPM standard-version

I have integrated standard-version into my javascript project. I made sure to include the release script in my package.json: "scripts": { ... "release": "standard-version" } However, after adding a commit with the mes ...

Modify the color of links when hovering using CSS

I am currently utilizing VScode and attempting to modify the link color on :hover. I am also interested in adding a grow Hover Effect. Here is my code snippet: .subareas a.link { margin: 0 0 10px 10px; float: right; height: 30px; line-height: 29 ...

When the window is resized, the css('position') method may return undefined

Here is the code I am using to detect the browser resize event: window.onresize = function(){ var style = $('#button-selection').css('position'); if(style == "relative"){ $("#button-section").css("position"," "); }else if(style == ...

I'm having trouble getting my paragraph to center with both Bootstrap 4's margin:auto and text

I've been trying to center a paragraph in my project but it's not working out. I attempted using margin:0px auto; and the text-center features, but they didn't have the desired effect. <div class="row text-center"> <p> You c ...

Creating a fixed navbar and footer using Node.js with Jade templating engine and Ajax

I am facing a challenge with rendering dynamic content between my static navbar and footer when clicking the links in my navbar. Each time I click a link, the content duplicates along with the navbar and footer. My setup involves using node with express an ...

Capture of Chrome pages is not possible when the extension has not been activated on the current page due to the absence of the activeTab permission

Hey there! I've encountered a tricky situation while trying to implement a Google extension. Due to technical limitations, I need to open the extension in a separate window as opposed to a disappearing pop-up, which is causing some issues with the fu ...

"Vue: Elevate Your Design with Seamless Color Trans

I am faced with the challenge of creating a transition effect for an overlay color when a button is clicked using Vue. Currently, the overlay appears abruptly, but I would like it to smoothly transition from a darker shade to a lighter one. As a newcomer t ...

ESLint encountered an error while attempting to load the configuration "next/babel" for extension

Every time I try to generate a build of my Next.js app by running "npm run build," I keep encountering this error. Check out the error I'm getting while running npm run build here. Also, take a look at my .eslintrc.json file here and my .babelrc file ...

How to access a file stored within a proxy object using Vue.js

I am currently working on sending a file from a vue-page to the server. To achieve this, I have implemented the following: FileFrom component: <template> <div class="FileForm" v-bind:name="name"> <label clas ...

Exploring the money library in typescript after successfully installing it on my local machine

I've been struggling to set up a new library in my TypeScript project for the first time, and I can't seem to get it functioning properly. The library in question is money. I have downloaded it and placed it in the root of my project as instructe ...

What could be causing jQuery to overlook the content within my div element?

I have a basic toggle feature for a div connected to a checkbox. $('#step2').hide(); $('#toggle-check').click(function(){ $('#step2').fadeToggle(); }) Why is .hide() not working to hide the contents of #step2? The content ...

Email text will be truncated with an ellipsis on two lines

Are there alternative methods to truncate text without relying on webkit-line-clamp? I need to implement this in an email, so using it is not an option. This is the current code snippet I am working with: <style> h2 { line-height:1.5rem; m ...

The view has no access to $scope but the controller does

I need to display the iso code using a $scope when selecting a country from a list. The list of countries is fetched through a $http call in a factory and then stored in a scope. ///////// get countries //////////////// tableFactory.getCountries().then(f ...

The method models.User.fromURI is unsuccessful

When I try to call models.User.fromURI as shown below: models.User.fromURI("spotify:user:" + user, function (user) { $(div).html("<b ><a style=\"color:#FFFFFF\" href=\"spotify:user:" + user.username + "\">" + us ...