@SgtLegend Any reason you are using the each method instead of caching the elements as a variable? I don't know that much about jQuery, so it is probably something simple.
@johsuanhibbert - I am not that advanced either so i thought this was a good spot to jump in...My take on it, is that since it is really only being referenced once (not making multiple similar requests to the DOM) then it really doesn't matter...hard to explain my thoughts without a really long winded response... EDIT: I spoke with my cousin's husband who is far more advanced than myself, and he agrees, but says perhaps your version may be a bit more readable than @SgtLegend 's
I suppose for sake of simplicity, not using ternary might make it a little more readable for anyone who doesn't yet understand it though too ;P
The $.each method simply allows for more flexibility and more maintainable code, personally i always choose it over calling a collection of elements unless its very simple like:
In this case calling the $.each method would be a waste since we can do a simple evaluation of the :checked status on the checkboxes, the same concept applies to the box toggle code.
I know it's been a while since my last post which probably seems fishy but I have just been busy, to see what i mean by my above comments see the following jsFiddle which has a built in feature that allows the boxes to open by default.
I'm trying to create a toggle by following the jsfiddle examples, but it's not working for me. Would someone be able to tell me what I'm doing wrong? I'm new to this. Thanks!
This is working fine. But I would like to toggle the "clickme text"
Something like this: http://css-tricks.com/snippets/jquery/toggle-text/
But I can't code it right ...
http://jsfiddle.net/wGbh5/
In your demo I see two click text.
My goal is something like this:
If I see the content in the "box" the click-text will be "Hide box"
http://jsfiddle.net/wGbh5/1/
I suppose for sake of simplicity, not using ternary might make it a little more readable for anyone who doesn't yet understand it though too ;P
$.eachmethod simply allows for more flexibility and more maintainable code, personally i always choose it over calling a collection of elements unless its very simple like:In this case calling the
$.eachmethod would be a waste since we can do a simple evaluation of the:checkedstatus on the checkboxes, the same concept applies to the box toggle code.thats exactly what I'm looking for ... but I'm using Drupal7 and jQuery 1.4.4
It have to be in jQuery 1.4.4
so fuc... awesome - tx :-)
http://jsfiddle.net/wGbh5/4/
I'm trying to create a toggle by following the jsfiddle examples, but it's not working for me. Would someone be able to tell me what I'm doing wrong? I'm new to this. Thanks!
http://jsfiddle.net/margaretcollins/TTbPL/1/