{"id":623,"date":"2012-08-17T06:55:37","date_gmt":"2012-08-17T06:55:37","guid":{"rendered":"http:\/\/codeatelier.wordpress.com\/?p=185"},"modified":"2012-08-17T06:55:37","modified_gmt":"2012-08-17T06:55:37","slug":"how-to-switch-states-jquery","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/how-to-switch-states-jquery\/","title":{"rendered":"How to Switch States Jquery"},"content":{"rendered":"<p><strong>How to Switch States in Jquery Between Yes or No<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/codeatelier.files.wordpress.com\/2012\/08\/upload.gif\" alt=\"\" width=\"488\" height=\"288\" \/><\/p>\n<pre>.CrossMe\n {\n    background : url(CrossMe.gif) no-repeat;\n    cursor     : pointer;\n    float      : left;\n    height     : 44px;\n    width      : 51px;\n }\n\n .TickMe\n {\n    background : url(TickMe.gif) no-repeat;\n    cursor     : pointer;\n    float      : left;\n    height     : 44px;\n    width      : 49px;\n }\n\n .NotInterested\n  {\n    background : url(NotInterested.gif) no-repeat;\n    cursor     : pointer;\n    float      : left;\n    height     : 44px;\n    width      : 241px;\n  }\n\n .Interested\n {\n    background : url(IamInterested.gif) no-repeat;\n    cursor     : pointer;\n    float      : left;\n    height     : 44px;\n    width      : 243px;\n }\n\n<\/pre>\n<p><b>Jquery to Change Class<\/b><\/p>\n<pre>\n$('document').ready(function(){             \n    $('.CrossMe').click(function(){\n        $(this).toggleClass('TickMe');\n\n        var prevClass = $(this).prev().attr('class');\n        if(prevClass=='Interested')\n        {\n          $(this).prev().removeClass('Interested').addClass('NotInterested');\n        } \n        else\n        {\n          $(this).prev().removeClass('NotInterested').addClass('Interested');\n        }\n    });\n});\n<\/pre>\n<p><b>HTML to create divs<\/b><\/p>\n<pre>\n  <div class=\"Interested\"><\/div>\n  <div class=\"CrossMe\"><\/div>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to Switch States in Jquery Between Yes or No .CrossMe { background : url(CrossMe.gif) no-repeat; cursor : pointer; float : left; height : 44px; width : 51px; } .TickMe { background : url(TickMe.gif) no-repeat; cursor : pointer; float : left; height : 44px; width : 49px; } .NotInterested { background : url(NotInterested.gif) no-repeat; cursor&hellip; <a href=\"https:\/\/codethataint.com\/blog\/how-to-switch-states-jquery\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-623","post","type-post","status-publish","format-standard","hentry","category-jquery"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=623"}],"version-history":[{"count":0,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}