zoukankan      html  css  js  c++  java
  • API图片路径和超链接语义化转换

    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="UTF-8">
    <title></title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript">
    $(function() {
    $('#test').click(function() {
    //alert(3)
    $.ajax({
    type: "GET",
    url: "http://api.tianapi.com/tiyu/?key=e817ca0e19e6e420e720c230ac1702d8&num=10",
    dataType: "json",
    success: function(data) {

    var txapi = " ";
    for(var i = 0; i < 10; i++) {
    console.log(data["newslist"][i]["picUrl"]);
    txapi += '<a href="' + data["newslist"][i]["url"] + '">' + '<img src="' + data["newslist"][i]["picUrl"] + '">' + "</a>"
    }
    $('#result').append(txapi);
    }
    });

    return false;
    })
    })
    </script>
    <style type="text/css">
    img {
    /* 100%;*/
    }
    </style>
    </head>

    <body>
    <input type="button" id="test" value="测试" />
    <div id="result">

    </div>
    </body>

    </html>

  • 相关阅读:
    webpack常见问题 收藏
    ES6 模块
    ES6 Class 类
    ES6 迭代器
    ES6 函数
    ES6 数组
    ES6 对象
    记一次pda(安卓)环境配置流程
    类型转换
    DOM事件
  • 原文地址:https://www.cnblogs.com/agen-su/p/8204055.html
Copyright © 2011-2022 走看看