给动态标签动态绑定事件

html

  <p>给商家留言<input id="text_shop_message_{{shipment.order.order_sequence_id}}" name="" type="text" style="300px;"></p>

js

  

 1         for(var i=0;i<arr.length;i++){
 2             if(arr[i].order.shop_id==0){
 3                 var orderSequenceId=arr[i].order.order_sequence_id;
 4                 $('#text_shop_message_'+orderSequenceId).bind("blur",(function(){
 5                    //this line
 6                     return function(e){
 7                         var param = {
 8                             orderSequenceId : orderSequenceId,
 9                             customerMessage : $('#text_shop_message_'+orderSequenceId).val()
10                         }
11                         CK.Ajax.post("/message/save", param, function(data) {
12 
13                                 });
14                       //this line
15                         e.stopPropagation();
16                     }
17                 })(arr[i].order.order_sequence_id));
18             }
19         }
原文地址:https://www.cnblogs.com/xlchen/p/5632499.html