Jquery获取类并在函数中使用

Jquery获取类并在函数中使用,jquery,Jquery,html 我对jquery不是很在行,现在我要做的是用类bubble淡出并淡出元素,出了什么问题 尝试将其作为参数传递: $(function () { function bubble () { $(this).fadeIn(300).delay(2000).fadeOut(400); } }); $( document ).

html


我对jquery不是很在行,现在我要做的是用类bubble淡出并淡出元素,出了什么问题

尝试将其作为参数传递:

 $(function () {

              function bubble ()
              {
                 $(this).fadeIn(300).delay(2000).fadeOut(400);
              }
            }); 
            $( document ).ready(function() {
               $(.bubble).bubble();
            }); 
$(“.bubble”)。每个(bubble)可能有效
 $(function () {

              function bubble ()
              {
                 $(this).fadeIn(300).delay(2000).fadeOut(400);
              }
            }); 
            $( document ).ready(function() {
               $(.bubble).bubble();
            }); 
function bubble (el)
{
    el.fadeIn(300).delay(2000).fadeOut(400);
}
bubble($('.bubble'));