Home jquery JQuery does not work at all! What could be the problem?

JQuery does not work at all! What could be the problem?

Author

Date

Category

jQuery does not work at all! What could be the problem? Here all the code post:

& lt; body & gt;
& lt; div id = "bg" & gt; & lt; / div & gt;
& lt; script type = "text / javascript" src = "script / myscript.js" & gt; & lt; / script & gt;
& lt; script type = "text / javascript" src = "script / jQuery-2.0.0.min.js" & gt; & lt; / script & gt;
& lt; / body & gt;

myscript.js:

$ ('# BG'). CSS ('Background-Color', '# 000');

put it:

$ (document) .ready (function () {
$ ('# BG'). CSS ('Background-Color', 'Green');
});

does not work and does not react! What’s the matter? My head is not working. In the morning I suffer over him.


Answer 1, Authority 100%

Change places, so:

& lt; script type = "text / javascript" src = "script / jQuery-2.0.0.min.js "& gt; & lt; / script & gt;
& lt; script type = "text / javascript" src = "script / myscript.js" & gt; & lt; / script & gt;

UPD:

Do you have what should happen? Judging by your code, the ID = “BG” block should be painted in green. It will happen if you add any content to this block or simply set the height via CSS. Without content and without explicit indication of height, the unit has zero height and as a result is not visible.


Answer 2, Authority 100%

You download scripts to the HTML document header. Therefore, the sequence matters. First you need to load jQuery and then executed script.


Answer 3

Background-color in javascript looks like backgroundsolor , by analogy All other elements with a Fname-Sname = & gt defis; FnamesName

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions