JQuery動態添加標簽


使用JQuery2.0.0動態添加標簽

$(function() {
// 請求json數組 $.ajax({ type: "POST", //請求方式 url: "https://api.jisuapi.com/area/province?appkey=***", //地址,就是json文件的請求路徑 dataType: "jsonp", //數據類型可以為 text xml json script jsonp success: function(result) { addSheng(result.result) } }); }); //在#dongdong-box中添加標簽 function addSheng(arr2) { // var arr2 = [ // ['https://news.edu.360.cn/', '教育'], // ['b', 'bb'], // ['c', 'cc'] // ]; $.each(arr2, function(i, item) { console.log(i + "====" + item.name);
//         選中id:the_province,使用append方法在標簽<div>后添加拼接標簽,</div> $('#the_province').append($('<a href="' + item.name + '">' + item.name + '</a>')); }) }

  


免責聲明!

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



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