как привязать событие к нескольким элементам
Доброго времени.
fade.on('click',function(){ close() }) closeButton.on('click',function(){ close() }) Хотелось бы поменять на что-то типа $(fade,closeButton).on('click', close) Но никак не работает. Подскажите что не так? |
Цитата:
|
this.fade = $('#fade') this.closeButton = $('<div class="close" />') |
Цитата:
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- <link rel="stylesheet" type="text/css" href="tmp.css" /> --> <style type="text/css"> </style> <script type="text/javascript"> $(document).ready(function (){ $('div, p').css('color','red'); }); </script> </head> <body> <div>div</div> <p>p</p> </body> </html> |
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
|
Так что, есть решение-то?
|
Решил таким способом:
fade.add(closeButton).on('click', close) |
Часовой пояс GMT +3, время: 05:15. |