Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Parse error in simple jquery code

Posted on 2011-09-09
5
Medium Priority
?
316 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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 …

604 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