win*_*xee 5 html javascript css ajax jquery
您好,我正在尝试实现投票系统,例如堆栈溢出,已经完成了后端//整个功能,但是在UI中显示它们时遇到了问题。现在,箭头看起来相距太远,数字还没有居中。另外,如果有可能,我希望在单击/取消单击时切换箭头的颜色。我已经尝试过了,但是UI一直很混乱。有人可以帮我吗?先感谢您。
<td class="vert-align">
<div>
<a href="/post/{{ post.slug }}/vote?is_up=1" class="vote">
<span class="glyphicon glyphicon-triangle-top" style="" aria-hidden="true"></span></a>
<br /> //upper arrow
<span class="number"><h4 id="vote_count_{{ post.slug }}">{{ post.get_vote_count }}</h4></span> <br> //number gets displayed here
<a href="/post/{{ post.slug }}/vote?is_up=0" class="vote">
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span></a>
</div> //under arrow
</td>
Run Code Online (Sandbox Code Playgroud)
我也有一个js文件进行投票
function vote(node) {
var thread_id = node.attr("href").split('\/')[2];
$.ajax({
url: node.attr("href"),
dataType: "json",
success: function(data) {
$("#vote_count_"+thread_id).html(data.count);
},
error: function(data) {
alert(data.responseJSON.error_message);
}
});
}
$("a.vote").on("click", function() {
vote($(this));
return false;
});
Run Code Online (Sandbox Code Playgroud)
谢谢。
要使用引导程序(我可以看到您正在使用它)实现此设计,您可以简单地使用此模板:
<div class="row">
<div class="col-md-1" style="font-size: 30px; color:#606060; text-align: center;">
<span class="glyphicon glyphicon-triangle-top col-md-12"></span>
<span class="col-md-12">0</span><!-- Number goes here -->
<span class="glyphicon glyphicon-triangle-bottom col-md-12"></span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果您想在单击时切换箭头颜色,请使用 Javascript 方法,该方法使用 var(布尔值)来确定按钮是否被单击,然后使用 jQuery 方法 .css() 您可以更改所需按钮的颜色。
实例 - http://www.bootply.com/6KzWhJefif
| 归档时间: |
|
| 查看次数: |
460 次 |
| 最近记录: |