jQuery 点击事件响应 自己写的 $(function(){}) 没有绑定成功

<scriptlanguage="javascript"type="text/javascript">$.fn.greate=function(){this.css({"... <script language="javascript" type="text/javascript">
$.fn.greate = function(){
this.css({
"background-color":"red",
"height":"10px",
"width":"10px",
"position":"relative"
}
);
}

$(function(){
$(".fly").animate({'left':'200'},500).greate()
})
$(function(){
$('#mont').click().parent().append('<div class="fly"></div>')

})
</script>
===============================
<style>
#mont{ width:30px; height:30px; background-color:#333;
position:relative}
</style>
===============================
<div id="mont"></div>

为什么我每一次点击 #mont 之后 生成的 .fly 没有绑定之前写的 greate()
展开
 我来答
zhaoapk
推荐于2016-06-02 · TA获得超过3771个赞
知道大有可为答主
回答量:1343
采纳率:40%
帮助的人:1583万
展开全部
$.fn.greate = function () {
    this.css({
        "background-color": "red",
        "height": "10px",
        "width": "10px",
        "position": "relative"
    });
}

$(function () {
  $('#mont').click(function () {
      var fly = $('<div class="fly"></div>');
      $(this).parent().append(fly)
      // 添加fly之后执行animate
      fly.animate({'left': '200'}, 500).greate()
  })
})

你是不想要这个效果呢?

TableDI
2024-07-18 广告
VLOOKUP 是 Excel 中一个非常实用的函数,它允许用户在一个区域或表格的首列中查找特定值,并返回同一行中指定列中的值。当进行跨表匹配时,你可以使用 VLOOKUP 函数将两个不同表格中的数据关联起来。通过指定查找值、表格数组、列号... 点击进入详情页
本回答由TableDI提供
hawkeyes0
2013-09-25 · TA获得超过600个赞
知道小有建树答主
回答量:484
采纳率:0%
帮助的人:138万
展开全部
$(function(){})
仅在页面加载完成时执行,并且根据你所写顺序执行
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式