先引入 jq 文件
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
无须使用 API,
把以下代码放入合适的位置即可,可自定义 css
01 | <button class= "support" >点赞</button> <!--按钮---> |
02 | <div id = "support_number" >{content:likes}</div> <!--赞数量--> |
03 | <p class= "supported" ></p> <!--已赞提示--> |
06 | $( '.support' ).on( 'click' , //绑定事件 |
09 | url: '{content:likeslink}' , //点赞链接 |
13 | success: function (data) { |
14 | $( '#support_number' ).load(location.href + " #support_number" ); //点赞后刷新#support_number |
15 | if (data.state) {} else { |
16 | $( ".supported" ).html( "已点赞!" ) //已赞提示 |
18 | error: function (xhr, status, error) { |
|