CSS类在使用jquery的mvc4中不工作

css class is not working in mvc4 using jquery

本文关键字:mvc4 工作 jquery CSS      更新时间:2023-09-26

我有一个视图页面,我在其中应用了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帮助我为什么发生…

Try

 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");
}

你的代码在这里工作