为单击事件添加代码

add code to click event

本文关键字:代码 添加 事件 单击      更新时间:2023-09-26

如何通过单击图像来执行以下代码?

$('#container').animate({'opacity': 0}, 1000, function () {
$(this).text('new text');
}).animate({'opacity': 1}, 1000);
$('yourimageselector').click(function () {
  $('#container').animate({
      'opacity': 0
  }, 1000, function () {
      $(this).text('new text');
  }).animate({
      'opacity': 1
  }, 1000);
});