Along the same lines, we  
have .addClass(), .removeClass(), .toggleClass(), but  
no .swapClass() . Not sure if you want to add another method, but it  
is kind of nice to be able to do something like $ 
('div').swapClass('old', 'new') instead of $ 
('div').removeClass('old').addClass('new').

I'm ambivalent about it, but thought I'd bring it up since we're sort  
of brainstorming.

--Karl





On Sep 26, 2008, at 2:54 PM, John Resig wrote:

>
> I've heard requests for that a lot - the ability to toggle text,
> toggle values, toggle attributes, toggle css.
>
> I wonder if something like this could be done:
> .text("value A", "value B")
> .val("value A", "value B")
> .css("display", "none", "block")
>
> and it sets the value to to opposite of what's currently shown. Just  
> a thought.
>
> --John
>
>
>
> On Fri, Sep 26, 2008 at 2:15 PM, Karl Swedberg  
> <[EMAIL PROTECTED]> wrote:
>> It's funny you mention this with the val() example, because I just  
>> wrote
>> something similar today, but using text():
>> var $toggleInfo = $('#toggleInfo');
>> $toggleInfo.text( $toggleInfo.text() == 'hide contact info' ?  
>> 'bring back
>> contact info' : 'hide contact info' );
>>
>> Kind of ugly.
>> Can't think of anything else at the moment, but will send them  
>> along if I
>> bump across anything.
>> Well, I can think of plenty of places where *my* code is inelegant,  
>> but not
>> where jQuery is to blame.
>> --Karl
>> ____________
>> Karl Swedberg
>> www.englishrules.com
>> www.learningjquery.com
>>
>>
>>
>> On Sep 26, 2008, at 1:59 PM, John Resig wrote:
>>
>> I'm curious: Are there any pieces of code that use jQuery, right now,
>> that you feel are unelegant or ugly? (Presumably ones that've already
>> been optimized to the best of their ability.)
>>
>> One area of improvement that I was thinking of was something along  
>> the lines
>> of:
>>
>> // ugly
>> $("#foo").val( $("#bar").val() );
>>
>> // a bit better
>> $("#foo").val( $("#bar") );
>>
>> this would be an easy change, just make .attr() do something like:
>>
>> if ( arg.jquery )
>> val = arg.val() || arg.text() || "";
>>
>> Any other thoughts? I wonder if there are common cases that could be
>> improved with some simple code additions to core.
>>
>> --John
>>
>>
>>
>>
>>
>>>
>>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to