我有以下代码,应该添加一个“活动”类 但它不起作用。
只有这两行对我有用。
var url = window.location.href + value;
document.location = url;
您看到此代码有任何问题吗?
$(document).ready(function() {
$(".btm_category").click(function() { // its .btm_category not .btn_category
$(this).addClass("active");
var value = $(this).val();
var url = window.location.href + value;
//document.location = url; // ignoring to check
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="btm_category" value="?user_category=206">IT</button>
<button class="btm_category" value="?user_category=180">Public</button>
<button class="btm_category" value="?user_category=181">Private</button>
<button class="btm_category" value="?user_category=176">officer</button>