• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamically change the class according to the variables

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm developing a Web application. As you see the picture I kept the menus as tabs in a separate file and called it to the main page using code.


there is no issue in it. I wanted to change the tabs classes according to the variables in the URL. I gave a try with javascript & jquery but it didn't work.

Banner File


Javascript File


I want to change add the current class the tabs which selected. Can some one help on this???
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At what point is it going wrong? Are the "parts" as you expected after the regex? Why are you using the replace() method?

Open the debugging console in your browser and set breakpoints in the code. That way you can look at the value of variables and find out at what point it is going wrong. Why guess when you can actually inspect the variable at run time?
 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:At what point is it going wrong? Are the "parts" as you expected after the regex? Why are you using the replace() method?

Open the debugging console in your browser and set breakpoints in the code. That way you can look at the value of variables and find out at what point it is going wrong. Why guess when you can actually inspect the variable at run time?



There is no issue in getUrlVars() method. It returns the URL variables. I'm quite sure there is something wrong with the code
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please make sure that the code you post is properly indented.

Did you open the debugging console? What error messages did you get?
 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please make sure that the code you post is properly indented.

Did you open the debugging console? What error messages did you get?



I've got the following error message on the console

Uncaught TypeError: Object #<HTMLUListElement> has no method 'removeClass' common_javascript.js:8
Got message from bg page - https://mail.google.com/mail/?view=cm&fs=1&tf=1 mailto.js:51
Starting to rewrite mailtos
 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please make sure that the code you post is properly indented.

Did you open the debugging console? What error messages did you get?



Further I have changed the script as follows


And now I am getting error as : "Uncaught ReferenceError: element is not defined"
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Elements do not have an addClass method. You need to wrap the element with jQuery to use jQuery methods. E.g. $(element).addClass()
 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Elements do not have an addClass method. You need to wrap the element with jQuery to use jQuery methods. E.g. $(element).addClass()



Thank you. I worked
 
Sumer Selvaraj
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found a solution for this problem. I was coming around the bush. Now I've hit the bush. The following code helped me to overcome this issue

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic