Solved

Parse error in simple jquery code

Posted on 2011-09-09
5
293 Views
Last Modified: 2012-05-12
Hi,

As you can see below in the code, i get a parse error.

The script works in chrome not in safari. (which i think is strange because they both use webkit)

What is wrong with the code and how can i fix it?

Thanks!
<script>
function class() {  
        
contact.php:31SyntaxError: Parse error

if ($('#55').hasClass('buttonactive')) 
{$('#55').removeClass('buttonactive').addClass('button');}
else 
{$('#55').removeClass('button').addClass('buttonactive');}
}
</script>

Open in new window

0
Comment
Question by:peps03
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36509623
try to use a valid ID
currently you're using only numbers

Check Attribute Values here for example to know the rules :
http://www.w3schools.com/tags/att_standard_id.asp
0
 

Author Comment

by:peps03
ID: 36509718
thanks.

i changed it to, but still get the error:
 
<script>
function class() {          
contact.php:31SyntaxError: Parse error

if ($('#a55').hasClass('buttonactive')) 
{$('#a55').removeClass('buttonactive').addClass('button');}
else 
{$('#a55').removeClass('button').addClass('buttonactive');}
}
</script>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 36509738
use an other function name else, post the php script
0
 

Accepted Solution

by:
peps03 earned 0 total points
ID: 36510750
hmm thanks for the input.

i managed to fix it this way:
$("#a<? echo $current . $current ?>").click(function () {
  $("#a<? echo $current ?>").removeAttr("href");
  $('#a<? echo $current . $current ?>').toggleClass('buttonactive').toggleClass('button');

Open in new window


the error was that the page loaded on every click.
0
 

Author Closing Comment

by:peps03
ID: 37175752
se last post
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now