Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created a sample jsf application, and am trying to use jquery. In what directory should the jquery.js file be located? web-inf? src? I downloaded the .js file, but it does not seem to be working. I'm not sure where it should be.

I have updated my code to point to the googleapis, but it still does not work:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">
        $(document).ready(function(){
            $("#p1").mouseenter(function(){
                alert("You entered p1!");
            });
        });
    </script>
    <p id="p1">Enter this paragraph.</p>
</h:body>

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
253 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can keep it anywhere as long as you give correct path to the file. But try to keep it away from the WEB-INF directory, keep only private file under that directory (files which are not directly accessible to users).

If you have a web-content directory, keep the jquery file under web-contentjs directory, so that you can access it via <path-to-your-app>/js/jquery.js.

But if you can try to use a CDN version of the file as given in the download section of jQuery. You can use either Google or Microsoft CDNs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...