js,html,jquery 點擊運行jquery 函數



通過按鈕觸發
html <script src="jquery.min.js"></script> <div id=qzs style="width: 382px;height:282px;position:absolute; background-color:#ff0000; left: 109px; top: 133px;"><a href="#" onClick=setInterval("shoppingcat()",1) >點擊我就運行js -jquery函數</a></div> js function shoppingcat(){ document.getElementById("qzs").style.display = "none"//不顯示 //document.getElementById("qzs").style.display = "block"//顯示 }



  http://jquery.cuishifeng.cn/jQuery.Ajax.html

 


一、通過按鈕觸發運行
document.getElementById("qzs") 通過div 的id定位 選擇 改變對象

二、直接打開網頁就運行 通過 ajax 聯系 php 到數據庫 取數據 還要打包成json格式
json 格式   {} 對象 【】數組
 
var  myChart = echarts.init(document.getElementById('bar_week'));
              var arr1=[],arr2=[],arr3=[];
              function arrTest(){
                $.ajax({
                  type:"post",
                  async:false,
                  url:"data.php",
                  data:{},
                  dataType:"json",
                  success:function(result){
				  //{"daming":[53,54,53],"ming":[56,59,57],"jin":[62,114,93],"zuo":[58,113,90]}
				  //[{"public_zao":53,"public_zhong":54,"public_wan":53}]
                    if (result) {

                      for (var i = 0; i < result.length; i++) {
                          arr1.push(result[i].public_zao);
                          arr2.push(result[i].public_zhong);
						  arr3.push(result[i].public_wan);
                      }

					  
					  
                    }
                  }
                })
                return arr1,arr2,arr3;
              }
              arrTest();
              var  option = {
                    tooltip: {
                        show: true
                    },
                    legend: {
                       data:['早餐報餐']
                    },
                    xAxis : [
                        {
                            type : 'category',
                            //data : arr1
							data: ["大明天","明天","今天","昨天"]
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            "name":"早餐報餐",
                            "type":"bar",//funnel  bar  柱形圖
                            "data":arr1,
							//barWidth : 39, //柱體大小
                             itemStyle: {        //上方顯示數值
                                  normal: {
										label: {
											show: true, //開啟顯示
											position: 'top', //在上方顯示
											textStyle: { //數值樣式
												color: 'black',
												fontSize: 16
											}
										}
										}
										}
                        }
                    ]
					

                };
                // 為echarts對象加載數據
                myChart.setOption(option);
            // }

  



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM