0

Strange little glitch in a function. I need to replace a class for an element. I can add class, but I don't want that. I need to replace the class. And it's not working. The variable passes with .addclass. and not the other way. maybe there's some syntax I'm not understanding?

here's what I've got:

 $('#dropdown1a li').click(function(){

              var chosen_leaf = $(this).attr('id');

              $('#uniqueleaf').css({display:"block"},800);
              $('#pic4').attr("src", "images/leaf_shapes/23/leafbg_13.gif");
              $('#uniqueleaf').attr('class','chosen');
              $('#leafshown').attr('class',chosen_leaf); // THIS doesn't work
             //  $('#leafshown').addClass(chosen_leaf); THIS WORKS
              $('#uniquename').css({display:"block"},800);

       }); 
2
Contributors
2
Replies
8
Views
4 Years
Discussion Span
Last Post by turpentyne
0

It gives no value. If I use .attr('class',chosen_leaf);, I get class=""
If I use .addClass(chosen_leaf);, I get class="_auriculate" or whatever other "_word" id that the clicked <li> has.

I suppose there's something like this maybe, that I could put first.

.removeclass(*),

But that seems extra-wordy

Edited by turpentyne

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.