?
Solved

Parse error in simple jquery code

Posted on 2011-09-09
5
Medium Priority
?
311 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
[X]
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
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

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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…
Suggested Courses

752 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