I am trying to combine multiple click functions with toggle class into one that will affect multiple elements separately. As seen on image i want to change css of element on click only for one which is inside same parent element as button ignoring any other elements with same class.

HTML: 

&lt;div style="display: inline-block"&gt;    
    &lt;section class="container2"&gt;
       1
    &lt;/section&gt;
    &lt;section&gt;
        &lt;p&gt;&lt;button id="button"&gt;change&lt;/button&gt;&lt;/p&gt;
    &lt;/section&gt;
&lt;/div&gt;


CSS:

.background {
    background: red !important;
}
.container2 {
    background: black;
    width: 100px;
    height: 50px;
    color: white;
}


jQuery:

var removeClass = true;

$("#button").click(function () {
    $('.container2').toggleClass('background');
    removeClass = false;
});

$(".container2").click(function() {
    removeClass = false;
});

$("html").click(function () {
    if (removeClass) {
        $(".container2").removeClass('background');
    }
    removeClass = true;
});

http://jsfiddle.net/dkhhecf2/1/


I know i can write something like this 


  $("#one, #two, #three").click...


But is there any other way?

http://i.stack.imgur.com/wJhKu.png

Any help would be greatly appreciated.


Question: Turn On Off GPS in ICS
Answer: Those restrictions are because of security issues. You should not try to achieve this case because it works now, but in next few days can be fixed - for example custom roms.

The best solution to manage GPS is to open Android's GPS preferences and let user to enable/disable GPS manually.