Switcher feature not functioning properly
I am trying to build a simple switcher feature.
What is happening right now is, if originally everyone is selected and if I click on only friends, 'selected' class is properly assigned to only friends and removed from everyone. But if originally only friends is selected, nothing happens.
- $(".switcher span").click(function(){
- $.ajax({
- type: "GET",
- url: "content/profile/index.cs.asp?Process=ChangeComm",
- success: function(data) {
- if ($(this).is('.public')) {
- $(".public").addClass('selected');
- $(".limited").removeClass('selected');
- } else {
- $(".limited").addClass('selected');
- $(".public").removeClass('selected');
- }
- return false;
- },
- error: function (data) {
- }
- });
- });
- <div class="switcher">
- <span class="desc">güncellemeler</span>
- <span class="public <% If strDisplayComm = 1 Then %>selected<% End If %>">everyone</span>
- <span class="limited <% If strDisplayComm = 0 Then %>selected<% End If %>">only friends</span>
- </div>