1

I've an image in my JSP page. I need to call the jquery function on click of that image. Please help me !!

JSP page look like,

<html>
    <body>
        <input type="image" id="closeAuction" value="Close Auction" align="right" src="images/close_auction.png" onclick="return endAuction();" disabled / > 
    </body>
</html>

My jquery function inside the script tag looks like,

<script src="JS/jquery-1.3.2.min.js">
    $(document).ready(function() {     
        $('#closeAuction').click(function() {
            location.reload();     
        });    
    });
</script>

But the script doesn't work!! Could anyone help on calling a function on image click..

2
  • 1
    You're missing a closing quote in your selector. Commented Dec 5, 2012 at 15:19
  • 2
    Any code contained in a <script> tag with a src attribute will be ignored Commented Dec 5, 2012 at 15:20

4 Answers 4

5

You are missing a quote.. $('#closeAuction')

Change $('#closeAuction) to $('#closeAuction')

Also you need to put it in a new script

<script src="JS/jquery-1.3.2.min.js"></script>
<script type="text/javascript"> //Added new `<script>` tag
   $(document).ready(function() {
     //added missing-v quotes 
     $('#closeAuction').click(function() {
        location.reload();     
     });    
   });    
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

sorry i missed the quote while pasting it here, quotes are giving properly in the application. Even though it isn't working !!
@Varsha You need to include it in a new script tags.
3

You're missing a closing quote and you also need to place your code in it's own script block. Try this:

<script src="JS/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {     
        $('#closeAuction').click(function() { // <-- note closing quote on selector.
            location.reload();     
        });    
    });
</script>

Is there a specific reason you're using such an outdated version of jQuery? You should try upgrading to 1.8.3.

Comments

1

Replace $('#closeAuction) with $('#closeAuction')

Thanks

Comments

0

You cannot put code inside a script tag that is used to load an external resource.

<script src="JS/jquery-1.3.2.min.js"></script>
<script>
$(document).ready(function() {     
    $('#closeAuction').click(function() {
        location.reload();     
    });    
});
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.