Justin Burgard
Justin Burgard

Reputation: 470

Jquery won't affect element/class in table

I am trying to update the CSS of our site via Jquery based on which user is logging in. I need to hide an element (#BCID) and a class (.BC). Both are located in table.

When I manually enter the CSS ("display:hide") everything looks perfect. When I attempt to do it with Jquery (.css), nothing happens. I have tested other CSS commands on other elements with this same script and they work fine (adding borders, changing font color, etc.). But any attempt to change these elements utterly fails.

<script type="text/javascript">
  $("document").ready(function() {
    var department = 'adam';
      $("#BCID").hide();
    if (department.toLowerCase() === "adam") {
      $('#BCID').css('border', '1opx solid black'); 
    }
    else {
      $("#SFID").css('display', 'none');
    }
  });
</script>

Upvotes: 0

Views: 50

Answers (1)

Ben Harvey
Ben Harvey

Reputation: 1843

It seems to be working ok here fiddle but you have an error in your syntax (1opx solid black) which might be throwing it out:

$("document").ready(function() {
    var department = 'adam';
    $("#BCID").hide();
    if (department.toLowerCase() === "adam") {
      $('#BCID').css('border', '1px solid black'); 
    } else {
      $("#SFID").css('display', 'none');
    }
  });

Upvotes: 1

Related Questions