Skip to content Skip to sidebar Skip to footer

Local JQuery.js File Not Working

I had downloaded jQuery.js file from jQuery.com .I have saved this file in 3 places, including JRE/Lib and desktop (where my HTML file which calls it is), to be sure that the jQuer

Solution 1:

Thanks! I found the solution to this problem, from a similar question posted in this forum, asked a year ago. Here is the link:

jQuery code doesn't work if I'm using a local jquery.js file, why?

The problem seems to have been incompatible encoding of the html and the js files. So I added the charset attribute to script tag of js. And the problem and 'Hello' both vanished at a click!


Solution 2:

Your code works for me. Please check the below code, I have just modified the location of the jquery.js file where mine is stored in a different location.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%--<script type="text/javascript" src="jquery.js"></script>--%>
<script type="text/javascript" src="../Scripts/jQuery/jquery-1.7.2.js"></script>
<script type="text/javascript">
    $(function () {
        $("#clas").click(function () {
            $(this).hide();
        });
    });
</script>
</head>

<body>
<p id="clas">Hello</p>
<p>Hi</p>
</body>

</html>

I assume the location of your js is not correct. Are you using the same path of js where you have this "html" or jsp page? Or you have the js files in a separate folder?

Additionally, you can try alternate way as below:

$("#clas").live("click", function () {
        $(this).hide();
    });

Please let me know if this helps.


Post a Comment for "Local JQuery.js File Not Working"