Solved

problem with jQuery removeClass, does not seem to be working

Posted on 2012-03-23
3
889 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

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

18 Experts available now in Live!

Get 1:1 Help Now