我有3个链接i菜单。并在点击链接时发布他们的ID:
小提琴:Fiddle
HTML:
<div class="home-content">
<div class="menu-bar">
<ul class="nav nav-tabs">
<li class="active" id="top_picks"><a href="#">Top Picks<sup>beta</sup></a></li>
<li><a href="#" id="popular">Popular<sup>beta</sup></a></li>
<li><a href="#" id="analysis">Friends analysis</a></li>
</ul>
<p class="custom-alert">Article changes everyday! come back for more fun......</p>
</div>
</div>
<div class="articleContent">This content changes when link is clicked</div>
JS:
$(function () {
$(".menu-bar li a").click(function () {
var category = $(this).attr('id');
$(".active").removeClass("active");
$(this).parent().addClass("active");
//$('label').css('color', selText);
// When user clicks o "top picks" then it does not post category to ivite_db.php
$.ajax({
url: "invite_db.php",
type: "POST",
data: {"link_menu": category},
success: function(data) {
$(".articleContent").html(data);
}
});
});
});
单击popular
和analysis
链接时,代码可以正常工作。但是,当点击top_picks
链接时,它会发布该类别吗?
它出了什么问题?
答案 0 :(得分:5)