在js中触发某个事件的时候,加载另外一个js

在写前端js的时候,需要对通过js追加的页面的标签进行控制。直接在js中写发现取不到 追加后的内容。 原来是页面加载的时候一直都找不到这个标签所以js不管用,通过在网上查看。发现了在某个事件触发的时候加载另外一个js。具体代码如下
//预选号js效果
$(document).ready(function(){
	    //查看和详情互相切换
	    $(".tab_tit li").unbind("click").bind("click",function(){     
	      		 var rel = $(this).attr("data-rel");
	      		 $(".btn_bg").show();      //显示关闭按钮
      		     if(!$(this).hasClass("up")){
		             $(this).html("详情");
		             $(this).addClass("up");
		      	     $(this).siblings().html("查看");
		      	     $(this).siblings().removeClass("up");
		      	     $(".tab_con").hide();
		      	     $(".tab_con").eq(rel).toggle();
	             }else{
		              $(".btn_bg").hide();    //隐藏关闭按钮
		              $(".tab_con").hide();
		              $(this).removeClass("up");
		              $(this).html("查看");
	              }
	      		
	      	});
      	//关闭预选红球
  		$(".btn_bg").unbind("click").bind("click",function(){
			  		 $(".tab_con").hide();
			  		 $(".tab_tit li").html("查看");
			  		 $(".tab_tit li").removeClass("up");
			  		 $(this).hide();
  		});
      	//添加已选球和删除预选球
  		$("span").unbind("click").bind("click",function(){
  		    if($(this).hasClass("btn_sp02")){
  		    	$(this).removeClass("btn_sp02");
  		    	if($(this).hasClass("btn_sp01")){
      		        yx_var=  $(this).html();
      		    	$(".tab_con_yx .btn_sp02").each(function(i,n){
	      		    	 var obj=$(n);
	      		         if(yx_var==obj.text()){
	      		    	    $(this).remove();
      		    		  }
      		    	 });
  		           }
  		    }else{
  		    	$(this).addClass("btn_sp02");
  		    	$(".tab_con_yx").append("<span class='btn_sp02' style='cursor:pointer' flag="+$(this).html()+">"+$(this).html()+"</span>");
  		    	   //对已选红球进行排序
  		            var ic = $(".tab_con_yx");
  		            var spans = ic.find("span");
  		            var arr = spans.get();
  		            arr.sort(function(a, b) {
  		                var ai = parseFloat($(a).attr("flag"));
  		                var bi = parseFloat($(b).attr("flag"));
  		                if (ai > bi) {
  		                    return 1;
  		                } else if (ai < bi) {
  		                    return -1;
  		                } else {
  		                    return 0;
  		                }
  		            });
  		            ic.append(arr);
  		          //对已选红球排序结束
  		    	$.getScript("ssqNew/js/ssq_hq_yltl.js", function() {
  		    	 
  		    	});
  		    } 
  		});
  		
  		
  		
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值