Does JavaScript behave like CSS in that on-page scripts will take a higher precedence over external scripts? The reason I ask is because I am wondering if I can override an external script's commands to change a CSS attribute on expansion of a mobile nav bar.
1 Answer
You cannot really override anything that a previous script adds to a DOM element.
It will run, and then you just have to do something else to it.
3 Comments
huzzah
This is what I wondered about. So, you could be possibly seeing a flash of undesired behavior before YOUR script comes and does its thing.
Naftali
@huzzah yep, that could and might happen. It is unavoidable unless you edit the original script.
Sir
@huzzah to minimize the undesires usually it comes to how speedy your machine is + the efficientcy of your code + the browser's engine.
$('element').css('color', '#fff');or does it happen through a bound event?$('element').click(function(){ $(this).css('color', '#fff') });or are you trying to over ride a variable? Please clarify