jquery change dynamic button color when its clicked and send it to a listbox
<p>I have problems to change background color of dynamic created buttons.I have lots of button on the page created dynamically.I want to have in the first click to the button to change background color to green on the second click i want to take this change back.Wıth below code i tried to do it with %2 ==0 but than i realized it second click could be on other button and even it is the second click i want to make it green.I think i have to loop through every button than apply below code but i couldnt do it(This was my first question).Second question is finally i would like to send just green buttons value (text value) to a listbox.Below is my code but i am not succeed it.Can you please help</p>

<pre><code>&lt;asp:ListBox ID="ListBox2" runat="server" Width="111px"&gt;&lt;/asp:ListBox&gt;


        $(function () {
            var count = 0;
            $('input[type=button]').on('click', function (e) {
                e.preventDefault();
                count += 1;
                if (count % 2 === 0) {
                    $(this).css('background-color', '#6FA478');
                    var value = $(this).value;
                    $("[id$=ListBox2]").append($('&lt;option/&gt;').text(value).attr('value', value));
                }
                else {
                    $(this).css('background-color', '');
                }
            });
        });     
</code></pre>
