秒杀

// alert(1);
// setInterval(function(){
//     alert(11);
//   $("#kw").val("时间");
// },1000);
//alert($("#su").attr("value"));


// var newNode = document.createElement("p");//创建P标签 
// newNode.innerHTML = "<script type='text/JavaScript' src='http://libs.baidu.com/jquery/2.0.0/jquery.min.js'></script>"; 
// document.body.appendChild(newNode);//如果使用该方法,则在body的最后添加元素 

function withjQuery(callback, safe){
    if(typeof(jQuery) == "undefined") {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "https://libs.baidu.com/jquery/2.0.0/jquery.min.js";
 
        if(safe) {
            var cb = document.createElement("script");
            cb.type = "text/javascript";
            cb.textContent = "jQuery.noConflict();(" + callback.toString() + ")(jQuery, window);";
            script.addEventListener('load', function() {
                document.head.appendChild(cb);
            });
        }
        else {
            var dollar = undefined;
            if(typeof($) != "undefined") dollar = $;
            script.addEventListener('load', function() {
                jQuery.noConflict();
                $ = dollar;
                callback(jQuery, window);
            });
        }
        document.head.appendChild(script);
    } else {
        setTimeout(function() {
            //Firefox supports
            callback(jQuery, typeof unsafeWindow === "undefined" ? window : unsafeWindow);
        }, 30);
    }
}
 
withjQuery(function($, window){
    $(function() {
    //alert("jQuery loaded"); 
       $("#su").val(0);   
     var btn = document.getElementById("su");
     btn.value = "test";  
      var i=0;
        setInterval(function() {
           i=i+1;
           $("#su").val(i); 
          // alert(i); 
        }, 500);

})();
},true);



// var text = document.getElementById("kw");
// text.value = "时间";

// $("#su").hide();
// alert(3);

 

posted @ 2016-11-14 14:06  Athook  阅读(165)  评论(0编辑  收藏  举报