I think this is not very perfect.
what do you think of this?
$(document).ready(function(){
$("#thing").toggle(function(){
function () {
$("#resultsview").removeClass('list').addClass('gallery');
}, function () {
$("#resultsview").removeClass('gallery').addClass('list');
Rewritten:
---
.gallery {background:red;}
.list {background:green;}
$(document).ready(function(){
$("#thing").click(function(){
$("#resultsview").toggle(
function () {
Ha! Great catch, Nathan! Can't believe I missed that one myself.
--Karl
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Sep 10, 2008, at 12:12 PM, Nathan wrote:
You need quotes around all selectors. So $(#resultsview) should be $
("#resultsview")
Also, I would
You need quotes around all selectors. So $(#resultsview) should be $
("#resultsview")
Also, I would download/use Firebug, as it will provide meaningful
error messages in the console which you will learn and/or can paste to
forum messages like this...
-Nate
On Sep 10, 9:46 am, unremarkable <[
Usually, (but not always), a toggle() is used in an onclick action.
Usually it is used to show or hide an element.
Try something more like this:
click
blah
blah
This way, everything within the div will be hidden or shown when you
click on the link.
I hope this helps!!
O
//Can't see anything obviously wrong with your code, but you could do
it this way instead:
$(document).ready(function(){
$("#thing").click(
function () {
$(#resultsview).toggleClass('gallery');
});
});
Then change your CSS to this:
.list {background:green;}
ul.gallery
6 matches
Mail list logo