为什么模糊事件只会触发一次?

时间:2016-04-17 06:54:47

标签: javascript jquery jquery-events

所以我有一个与click事件类似的函数,它每次都有效,但是这个函数只触发一次?有什么想法吗?

$(document).ready(function() {
  $('.changecat').blur(function(event) {
    event.preventDefault();
    var catId = event.currentTarget.id;
    var catValue = $(event.currentTarget).val();
    jQuery.ajax({
      url: window.location.pathname,
      type: 'POST',
      data: {
        changeCat: catId,
        catValue: catValue
      },
      success: function(response) {
        $('#categorized').html(response);
      }
    });
  });
});

HTML的一部分:

<div id="categorized" style="margin-top:50px;margin-bottom:50px;" class="col-sm-12">
  @foreach ($category as $c)
    @if ($c->category !== "")
    <div id="{{$c->id}}" class="col-sm-4"><button type="button" data="{{$c->id}}" class="{{$c->id}} category btn btn-danger center-block">{{$c->category}}</button><br/><input id="{{$c->id}}" class="changecat center-block text-center" type="text" value="{{$c->category}}" /></div>
    @endif
  @endforeach   
</div>  

0 个答案:

没有答案