There is a code:

$('#pollSlider-button').click(function () { if ($(this).css("margin-right") == "300px") { $('#mask').remove(); $('.pollSlider').animate({ "margin-right": '-=300', }); $('#pollSlider-button').animate({ "margin-right": '-=300' }); } else { // Add the mask to body $('body').append('<div id="mask"></div>'); $('#mask').fadeIn(300); $('.pollSlider').animate({ "margin-right": '+=300', "width": '=300' }); $('#pollSlider-button').animate({ "margin-right": '+=300', "width": '=300' }); } }); 

So, when you click on # pollSlider-button, all the work happens, but I need to, that if I clicked on # pollSlider-button and #mask, the action occurred. Tell me how to correct.

  • Is it already forbidden to add multiple selectors? $ ('# pollSlider-button, # pollSlider-button, #mask'). click (function () {}); Of course, it’s more logical for such a group of elements to set up a single class and use it as a selector, but this is your business. - Deonis
  • added as a group, here it is #mask #mask {display: none; background: # 000; position: fixed; left: 0; top: 0; z-index: 10; width: 100%; height: 100%; opacity: 0.8; } I click on it, nothing happens. - foozzi

1 answer 1

Not?

http://jsfiddle.net/RubaXa/UT4wJ/1/

  • wrote the same did not help - foozzi
  • @foozzi, in such cases, lay out the code on jsfiddle.net . But you are a new person on the forum ( only 1 year and four months ), and you may not have known about it yet. - Deonis
  • @foozzi, and you changed the second line, just like me? - RubaXa
  • use .on() at you '#mask' is recreated ... - zb '