Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery conditional: if div has a particular ID, add class to another div

I am trying to get a jQuery conditional to apply a class to this particular element – – when another element contains a particular ID. Here's what I have so far:

<script type="text/javascript">
$(document).ready(function() {
if( $('.container-fluid').hasId('europe') === true ) 
{
 $('controlBar_playerVideo1').addClass('darkcontrols');
}
});
</script>

Here's the live site: http://fsa.space/

When I add the script above to the footer I get an "undefined is not a function" error in the console. I should mention I am a total jQuery novice (which should be abundantly apparent).

I would be grateful if someone could provide pointers to achieve this.

like image 750
bjornfloki Avatar asked Jan 18 '26 06:01

bjornfloki


1 Answers

try this

<script type="text/javascript">
$(document).ready(function() {
if ($('.container-fluid').attr("id") == "europe") {
         $('controlBar_playerVideo1').addClass('darkcontrols');
  }
 });
    </script>
like image 119
Ali Nirabi Avatar answered Jan 19 '26 20:01

Ali Nirabi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!