Jquery functions properly within jsFiddle, however it does not successfully execute within web browsers

Here is the code that seems to only function properly in jsfiddle, but doesn't work when used in browsers:

http://jsfiddle.net/5r6mx/18/ Here is the code that I am using in the browser, which can also be found in the jsfiddle link above:

// JavaScript

$(document).ready(function() { 
$(".image_stack").delegate('img', 'mouseenter', function() {
    if ($(this).hasClass('stackphotos')) {

        var $parent = $(this).parent();

$parent.find('div.namehover').addClass('rotate3');
$parent.find('div.namehover').css("left","77px");          
$parent.find('img#photo1').addClass('rotate1');
$parent.find('img#photo2').addClass('rotate2');
$parent.find('img#photo3').addClass('rotate3');
$parent.find('img#photo1').css("left","150px"); 
$parent.find('img#photo3').css("left","50px");
   }
})
.delegate('img', 'mouseleave', function() {
    $('img#photo1').removeClass('rotate1');
        $('img#photo2').removeClass('rotate2');
        $('img#photo3').removeClass('rotate3');
        $('div.namehover').removeClass('rotate3');
 $('div.namehover').css("left","");   


        $('img#photo1').css("left","");
$('img#photo3').css("left","");

});;
});

HTML

<div style="border:0px;clear:both;padding-bottom:240px;">

 <div class="image_stack" style="margin-left:0px;" >
 <img id="photo1" class="stackphotos" src="http://www.commentsyard.com/cy/01/6474/Mixed%20Flowers%20and%20a%20Bear.jpg"  >
 <img id="photo2" class="stackphotos" src="http://www.commentsyard.com/cy/01/6474/Mixed%20Flowers%20and%20a%20Bear.jpg" >
 <img id="photo3" class="stackphotos"  src="http://www.commentsyard.com/cy/01/6474/Mixed%20Flowers%20and%20a%20Bear.jpg" >

 <div class="namehover"> Perfumes</div>

 </div>

CSS

.image_stack img { /* CSS style for photo stack */
border: none;
text-decoration: none;
position: absolute;
margin-left:0px;
width: 170px;
height: 180px;
}
.image_stack { /* CSS style for photo stack */
width: 200px;
position: relative;
padding-left:20px;
margin-bottom:40px;
float:left;

}
.image_stack img { /* CSS style for photo stack */
position: absolute;
border: 4px solid #FFF;
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
z-index: 9999;
/* Firefox */
-moz-transition: all 0.2s ease;
/* WebKit */
-webkit-transition: all 0.2s ease;
/* Opera */
-o-transition: all 0.2s ease;
/* Standard */
transition: all 0.2s ease;
}
.image_stack #photo1 {  /* Position of last photo in the stack */
top: 8px;
left: 108px;
}
.image_stack #photo2 {/* Position of middle photo in the stack */
top: 6px;
left: 104px;
}
.image_stack #photo3 {/* Position of first photo at the top in the stack */
top: 4px;
left: 100px;
right: 100px; 
}
.image_stack .rotate1 {/* Rotate last image 15 degrees to the right */
-webkit-transform: rotate(15deg); /* Safari and Chrome */
-moz-transform: rotate(15deg); /* Firefox Browsers */
transform: rotate(15deg); /* Other */
-ms-transform:rotate(15deg); /* Internet Explorer 9 */
-o-transform:rotate(15deg); /* Opera */
}
.image_stack .rotate2 {/* CSS not used */
-webkit-transform: rotate(0deg); /* Safari and Chrome */
-moz-transform: rotate(0deg); /* Firefox Browsers */
transform: rotate(0deg); /* Other */
-ms-transform:rotate(0deg); /* Internet Explorer 9 */
-o-transform:rotate(0deg); /* Opera */
}
.image_stack .rotate3 {/* Rotate first image 15 degrees to the left */
-webkit-transform: rotate(-15deg); /* Safari and Chrome */
-moz-transform: rotate(-15deg); /* Firefox Browsers */
transform: rotate(-15deg); /* Other */
-ms-transform:rotate(-15deg); /* Internet Explorer 9 */
-o-transform:rotate(-15deg); /* Opera */
cursor: pointer;
}
.namehover {
position:absolute;
left:105px;
top:167px;
z-index:99999;
display:block;
background:#333;
color:#fff;
width:169px;
}

Answer №1

To verify if your script is located externally or on the html page, insert console.log("verifying script"); at the beginning of your javascript function, immediately following $(document).ready(function() {. After loading the page, inspect your console using firebug/chrome developer tools. If you do not see "verifying script" in the console log, then your script is not connected to the HTML page.

If this is the case, review your resource files and ensure there are no errors in the file path.

Answer №2

JSFiddle automatically provides jQuery. Are you ensuring jQuery is correctly embedded in your application?

Check the JavaScript console in the browser for any specific error messages and share them here.

Answer №3

Incorporating it into your HTML documents is essential. Unfortunately, it seems like that's not currently being done. Your webpage requires code similar to the following:

<script type="text/javascript" src="jquery.js"></script>

Answer №4

Have you attempted using the full path for the .js files?

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>

<!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->

Answer №5

// This jQuery code snippet is specifically designed for the photo stack feature and does not apply to single image zoom effects.
$(document).ready(function() { 
$(".image_stack").delegate('img', 'mouseenter', function() {
    if ($(this).hasClass('stackphotos')) {
        var $parent = $(this).parent();
        $parent.find('div.namehover').addClass('rotate3');
        $parent.find('div.namehover').css("left","77px");  
        $parent.find('img#photo1').addClass('rotate1');
        $parent.find('img#photo2').addClass('rotate2');
        $parent.find('img#photo3').addClass('rotate3');
        $parent.find('img#photo1').css("left","150px");
        $parent.find('img#photo3').css("left","50px");

    }
})
.delegate('img', 'mouseleave', function() {
    $('img#photo1').removeClass('rotate1');
    $('img#photo2').removeClass('rotate2');
    $('img#photo3').removeClass('rotate3');
    $('div.namehover').removeClass('rotate3');

    $('img#photo1').css("left","");
    $('img#photo3').css("left","");
    $('div.namehover').css("left","");

});
});

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

Limit the bootstrap datepicker to display only certain dates and today's date

I've integrated the Bootstrap Datepicker into my website. I need to customize it so that only specific dates are enabled, including today's date, and all other years, months, and days are hidden from the Datepicker. How can I achieve this? Furth ...

Using Lazy Load Plugin for jQuery to enhance Backbone.js functionality

I am working on a Backbone.js application using require.js and underscore.js. I am trying to incorporate the jquery lazy loading plugin with the Eislider banner. The Eislider banner was functioning properly before implementing the lazy loading script. Th ...

Navigate only within the tbody section of the Material UI Table by scrolling

Utilizing the material-ui Table component to build a table with a sticky header presents a challenge. The default behavior is for the scroll to encompass both the thead and tbody of the table. However, I specifically require the scroll functionality to be ...

Mastering Jquery mobile for efficient mobile analytical insights

I am on the lookout for a top-notch mobile analytics solution that can seamlessly integrate with Jquery Mobile. I've already explored this specific query: Flurry Analytics vs Google Analytics on the mobile platform However, those recommendations are ...

Chart: Observing the Discrepancy in the Initial X-Axis Points

I'm working on incorporating multiple charts onto one page, with each chart centered and stacked one after the other. I've set a fixed width for the graph canvas. The challenge arises from the varying ranges of tick values - one chart may have a ...

Overriding Divs with Navigation

In my WordPress blog, the top menu consists of 3 divs: one for navigation, one for social icons, and one for the search bar. Unfortunately, the navigation div is currently overriding the other two divs, causing them to lose their functionality. When I ad ...

How to Place Buttons on the Left, Center, and Right in Bootstrap Framework

I'm currently working on developing some pages using bootstrap. In the form at the bottom, I have three buttons - Save, Cancel, and Commit. The issue I'm facing is that while the left and right buttons are perfectly aligned, the Cancel button is ...

When async is set to true in an Ajax call, the response may come

I recently developed a function that works perfectly fine when the async option is set to false. However, I am now looking to achieve the same functionality and return value but with async set to true. function Call(param, proc) { var url = "../../ ...

Choose from the dropdown menu that selects the same nth occurrence of an element

I have a series of buttons listed below: <button id="serviceModal1" data-toggle="modal" data-target="#serviceModal1" tabindex="-1">Price 150€</button> <button id="serviceModal2" data-toggle="modal" data-target="#serviceModal2" tabindex=" ...

What is the best way to select a checkbox that is dynamically loaded through AJAX?

This approach is ineffective as the checkbox is not currently present in the Document Object Model (DOM): $('input[type=checkbox][name=rememberme]').prop('checked', true); I'm unsure about utilizing .on() since I don't have ...

Animating Array of Paragraphs with JQuery: Step-by-Step Guide to Displaying Paragraph Tags Sequentially on Each Click

var phrases = ['phraseone', 'yet another phrase', 'once more with feeling']; $(".btn").on('click', function() { for(var i=0; i < phrases.length; i++) { container.innerHTML += '<p>' + ...

What is the best way to ensure that the user interface stays updated with alterations made to

I am currently studying various front end design patterns, and I repeatedly come across the idea of implementing a virtual shopping cart in a shopping cart scenario. The suggestion is to have the user interface actively monitor any changes to the cart and ...

Submitting values to a different page in PHP using jQuery AJAX

I am having trouble sending data to another page using jQuery AJAX and PHP. Below is the form located in page1.php: <form method="post" action="page1.php"> Name : <input type="text" id="N_Txt"> Email : <input type="text" id="Emai ...

Generating dynamic data to be used in jQuery/ajax calls

I have a web method that I need to call using jQuery ajax. [System.Web.Services.WebMethod] public static int saveDataToServer(string cntName, string cntEmail, string cntMsg) { // Implementation } Here is my jQuery ajax calling method... functio ...

Menu with full-width navigation and dropdown options

I am trying to create a navigation menu with a black background that spans the full width of the window. To achieve this, I have placed the ul element inside a div with overflow: hidden; set. However, I am facing issues where hovering over submenus causes ...

Identifying with a jQuery IF statement all input fields that contain null values in order to eliminate the respective elements

My goal is to create a jQuery script that checks all input fields to see if they are empty. If an input field is empty, I want to remove the child image of the next occurring span element. Here is what I have attempted so far: if ($("input").val() == "") ...

What is the best way to tally data-ids within an anchor tag using jQuery or plain JavaScript?

find total number of data-id attributes within tag a I am looking for a way to calculate the count of my id attribute, whether it is in data-id or another form, using JavaScript. Edit ...

Discover the seamless integration of using Angular UI select2 with Angular 1.2.5 for a smooth user

I am attempting to make this jsfiddle compatible with angular 1.2.5 instead of just 1.0.5. http://jsfiddle.net/hWXBv/25/ <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script> The goal is to create a Gmail-lik ...

Customize your search experience with Google Custom Search Engine for Internet Explorer

Currently, I am integrating Google Custom Search (Business Edition) into my website using the Custom Element instead of the iFrame. I chose a theme that looks great on all browsers except for IE6. In IE6, the search results are displaying with the Promotio ...

Suggestions for creating a simple implementation of a 3 x 3 cell layout with a large center using flexbox are

Creating a grid layout like this 3 x 3 cell with large center using CSS Grid is quite straightforward. .container { display: grid; grid-template-columns: 60px 1fr 60px; grid-template-rows: 60px 1fr 60px; } But what if we wanted to achieve the same ...