Solved

Parse error in simple jquery code

Posted on 2011-09-09
5
291 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

746 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

10 Experts available now in Live!

Get 1:1 Help Now