Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
49
rated 0 times [  51] [ 2]  / answers: 1 / hits: 19693  / 10 Years ago, mon, february 24, 2014, 12:00:00

So I have checked my script tags in my .jsp file:



<script type=text/javascript src=javascript/jquery-1.3.1.min.js></script>

<script language=JavaScript > some content here .... </script>


and below in the same .jsp file I have a tag:



<body BGCOLOR=white text=black link=blue vlink=red onLoad=functionName();enableBackButton();>


However, in my JavaScript file I have:



$(document).ready(function(){
$('current').click(function(event){

function functionName() { ....... }


Somehow I keep getting an error in my Chrome console stating:



Uncaught ReferenceError: functionName is not defined


More From » jquery

 Answers
4

Move your functionName() out side of $(document).ready(function(){



function functionName() { ....... }

$(document).ready(function(){
$('.current').click(function(event){
functionName();
});
});


Also, you need to use . to target element by class or # to target element by id



So $('.current') will select any element with class=current and $('#current') will select an element with id=current



Last note is to update your jQuery version since 1.3.1 is extremely outdated already and it lacks of many helpful and important features which is supported by later versions.


[#72337] Sunday, February 23, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darrell

Total Points: 109
Total Questions: 113
Total Answers: 113

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
;