Solved

problem with jQuery removeClass, does not seem to be working

Posted on 2012-03-23
3
891 Views
Last Modified: 2012-03-23
On this page:

http://www.stoneridgeretirement.com/v3/independent-living.asp

In the main navigation, the first button labeled Independent Living has a class of "bt" which is what swaps out the image for the mouseover effect. However, on that page I don't want the mouseover effect on that button because you are "on" that page. So I have this on that page:

<script language="javascript" type="text/javascript">
      $(function(){
            $('#home2').css('width','980px');
            $('#home2').css('padding','0px');
            $('#home1').html('<img src="art/gr_independent-living.jpg" width="980" height="356" border="0" alt="Redefining Retirement" />');
            $('#home2').html('<img src="art/gr_independent-living.jpg" width="980" height="356" border="0" alt="Redefining Retirement" />');
            $('#mainnav2').attr('src','art/bt_7b.jpg');
            $('#mainnav2').removeClass('bt');
      });
</script>

Where I have removeClass('bt') I was hoping that would eliminate the mouseover, however it does not. I am having trouble figuring out if the class is being removed, or if there is some other problem. Would appreciate another set of eyes.

Thank you!
0
Comment
Question by:bbdesign
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Gary Davis earned 500 total points
ID: 37757219
I displayed your page in IE9, clicked F12, did a search for mainnav2 and saw this:

<img id="mainnav2" class="mainnav" border="0" alt="Independent Living" src="art/bt_7.jpg" width="147" height="65">

So it looks like the "bt" class is being removed by your jquery.

The IE devtools are also useful for script debugging to set breakpoints like in the code that removes the class (which seems to be working).

The mouseover issue is another problem.

Gary Davis
0
 

Author Comment

by:bbdesign
ID: 37757892
Thanks for looking. I ended up have to do a check in my mouseover function, to verify that it actually has the "bt" class before doing anything.
0
 

Author Comment

by:bbdesign
ID: 37757898
For some reason, the mouseover doesn't realize the class has been removed.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 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

22 Experts available now in Live!

Get 1:1 Help Now