Parse error in simple jquery code

Posted on 2011-09-09
Last Modified: 2012-05-12

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?

function class() {  
contact.php:31SyntaxError: Parse error

if ($('#55').hasClass('buttonactive')) 

Open in new window

Question by:peps03
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 82

Expert Comment

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

Check Attribute Values here for example to know the rules :

Author Comment

ID: 36509718

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

if ($('#a55').hasClass('buttonactive')) 

Open in new window

LVL 82

Expert Comment

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

Accepted Solution

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.

Author Closing Comment

ID: 37175752
se last post

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send email using HTML and PHP in separate file 5 41
Add a little space on either side of a table. 12 25
Echo'd values in dropdowns 6 30
Javascript: Range object 16 14
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

733 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