Reputation: 479
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..
Upvotes: 1
Views: 30995
Reputation: 195992
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>
Upvotes: 0
Reputation: 2653
Replace $('#closeAuction)
with $('#closeAuction')
Thanks
Upvotes: 1
Reputation: 79830
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>
Upvotes: 5
Reputation: 337560
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.
Upvotes: 3