The jQuery Hide function does not work in Firefox

advertisements

I'm trying to perform a simple hide function with jQuery, which works fine in IE10, but does not work in Firefox (25.0.1). The set-up is basically as follows: I have a base HTML page with a content block and a button. Clicking the button should load html from another (local) page into the content block, but certain parts (in this case the divs with a class of "description") should be hidden. Here's the code:

Base HTML page:

<!DOCTYPE html>
<html>
<head>
<title>Test for jQuery Hide function in Firefox</title>
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="../jquery.min.js"></script>
<script type="text/javascript" src="hide.js"></script>
</head>

<body>
    <div id="contentblock">This is where the content goes</div>
    <div id="button">Button</div>

</body>
   </html>

HTML to be loaded:

<!DOCTYPE html>
<html>
<head>
    <title>Test 2</title>
</head>
<body>

<div class="step">
<div class="stepcontent">This is the second file, first div</div>
<div class="description">Description #1</div>
</div>

<div class="step">
<div class="stepcontent">This is the second file, second div</div>
<div class="description">Description #2</div>
</div>

<div class="step">
<div class="stepcontent">This is the second file, second div</div>
<div class="description">Description #3</div>
</div>

</body>
</html>

jQuery:

$(document).ready(function(){

    $('#button').click(function(){
        $('#contentblock').load( 'loadfile.html' );
        $('.description').hide();

    });
});

Again, the above code works fine in IE10, but not in Firefox. I have no way right now to check it in Chrome, since Chrome doesn't allow loading of locally stored HTML into another HTML page. Thanks in advance for any help you can give.


To allow firefox to load local files (which may be where your script is halting), access the firefox config by typing "about:config" into the address bar.

Search for "origin" and set "security.fileuri.strict_origin_policy" to false.