我有一个 View 页面,我在其中应用了一个 Jquery
<script type="text/javascript">
$(document).ready(function () {
var hdrname = $('#headername').text();
alert(hdrname);
if (hdrname == "Pending Assignment") {
$('#lst1').addClass('highlight1');
alert("hcsgiahf");
$('#tab2').removeClass('highlight1');
}
else if (hdrname == "Assigned With L1 Support") {
alert($('#tab1').text());
alert("hello");
$('#tab1').removeClass('highlight1');
$("#tab2").addClass("highlight1");
}
//To get No of call start
});
//To get No of call end
但是当我运行我的页面时,css 类 highlight1 没有应用到指定的 id,any1 能帮我解释为什么会发生吗..
最佳答案
尝试
if (hdrname == "Pending Assignment") {
$('#tab1').addClass('highlight1');// i think you are wrong here
alert("hcsgiahf");
$('#tab2').removeClass('highlight1');
}
else if (hdrname == "Assigned With L1 Support") {
alert($('#tab1').text());
alert("hello");
$('#tab1').removeClass('highlight1');
$("#tab2").addClass("highlight1");
}
关于javascript - css 类在使用 jquery 的 mvc4 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24932767/