Why isnt jQuery appearing in my page [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have my "good.html" and "jquery.js" file in a folder on desktop called "jquery2."
Here is my code
<!doctype html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
console.log('ready');
});
</script>
</body>
</html>

Your
<script type="text/javascript" src="jquery.js"></script>
is not referencing the file on your desktop.
In order to make this work, you should upload the files to a server.

You don't need a server but you do need to use a good path to the javascript file on your desktop, on windows like so:
<script type="text/javascript" src="C:\Users\username\Desktop\jquery2\jquery.js"></script>
works for me on windows 7 with chrome browser. console shows ready.
If I make the path bad, console shows "Uncaught ReferenceError: $ is not defined" followed by a red X box next to
GET file:///C:/Users/wrongusername/Desktop/jquery2/jquery.js

Its issue with your Javascript path... put on same folder of your code or
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
more info
Where do you include the jQuery library from? Google JSAPI? CDN?

<script type="text/javascript">
$(document).ready(function(){
alert('ready');
});
</script>

Related

Can`t load jQuery library [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm trying to load jQuery library following videos but it does not work. When I'm trying to load some jQuery function, it writes that jquery is not defined. I also tried CDN.
<title>
GRID
</title>
<link rel="stylesheet" href="grid.css">
<link href="https://fonts.googleapis.com/css?
family=Ubuntu&display=swap" rel="stylesheet">
<script src="jquery-2.1.1.min.js"></script>
<script src="script.js"></script>
</head>```
You need to put jquery-2.1.1.min.js file into same location where your quoted file is if we are talking about local purposes.
If your prefer to download it each time, you can use for example Google Hosted Libraries in following way:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Like so <script src="jquery-2.1.1.min.js"></script>, jquery have to be in the root of your domain, like your script.js.
If you want CDN, use:
<script rel="prefetch" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>
Or official jQuery CDN:
<script
rel="prefetch"
src="https://code.jquery.com/jquery-2.1.1.min.js"
integrity="sha256-h0cGsrExGgcZtSZ/fRz4AwV+Nn6Urh/3v3jFRQ0w9dQ="
crossorigin="anonymous">
</script>

I am new to programming and I cannot figure out why my external js file wont work [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I cant get my external file to work. I just want a simple alert, it works in my main html file but not when I link the external js file.
<!doctype html>
<html>
<head>
<title>Javascript Tutorial</title>
</head>
<body>
<div class="container">
<h1>Let's Learn Javascript!</h1>
<p class="lead">...cause Javascript Rocks.</p>
</div>
<script src="scripts/main.js"></script>
</body>
</html>
It is proper practice to define script tags in the <head> or <footer> tag. Also when linking to your Javascript file the methods in the file won't be called automatically unless you use document.ready.
If you wish for a function to be called as soon as the page loads use document.ready or create a script tag in the <head> or <footer> and call the function from there:
<script type="text/javascript">
myfunction();
</script>
Also in the JS file code shouldn't just be laying about, they should be organized/enclosed in functions.

Load .html into div by using a search bar [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm primarily wondering if this is even possible without PHP, and perhaps some guidance if it is. I have the feeling I'm overthinking the process.
Currently I'm loading specific .html's into a div with ease by button clicks. However, I have been trying to load an .html into a div by using a search bar (as the title explicitly states).
For instance, I search for "Apple" and expect "Apple.html" to load into the div. I understand that javascript cannot/shouldn't search local files without the aid of PHP, but can it not 'assume' that the file is there and load it? According to my logic it wouldn't be much different than a button click.
you can use jquery
your all files should be at same place where actual page exist otherwise you have to specify path also.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>html</title>
<script src="http://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<input type="search" id="search">
<input type="button" id="button" name="">
<div>
</div>
<script type="text/javascript">
$("#button").on('click', function(e){
$('div').load($("#search").val() + ".html");
});
</script>
</body>
</html>

How to write basic lines in Javascript [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am new to programming and going through a "Beginning Programming" book. It lists the following code to write basic lines on a website:
<!DOCTYPE html>
<html>
<body>
<h1>This is a Test</h1>
<script>
document.write("<p>I like to code</p>");
document.write("<p>I will succeed at coding</p>");
</script>
</body>
</html>
Unfortunately, the line
document.write("<p>I like to code</p>");
does not give the desired output of "I like to code" written on the website.
How should this be written to get this output?
Your code seems to be running fine. Try updating your HTML file to this:
<!DOCTYPE html>
<html>
<body>
<h1>This is a Test</h1>
<script>
document.write("<p>I like to code</p>");
document.write("<p>I will succeed at coding</p>");
</script>
<noscript>
Javascript is disabled!
</noscript>
</body>
</html>
and if you see "Javascript is disabled!" then you'll need to allow your browser to use javascript.
Good luck :)
<!DOCTYPE html>
<html>
<body>
<h1>This is a Test</h1>
<script>
document.write("<p>I like to code</p>");
document.write("<p>I will succeed at coding</p>");
</script>
</body>
</html>
Seems to be running fine. Copy pasted same code

Chrome shows html too late [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have made a slider, based on flexslider. The slider is working perfectly, except for Chrome. All latest versions of FF, IE, Safari work fine, but Chrome isn't. Normally it's the other-way around...
See my slider here: http://test.postitief.nl/slider/.
What you will see (I hope) is that the with transparency including the text is show after the animation is done. It doesn't slide with the animation. All other browser slide this text without a problem and immediately show it.
Added video's
Video of how the slider should work (IE10): link
Video of how the slider works in Chrome (v29): link
Added code
code http://jsfiddle.net/zwFhe/
Edit
I found an equal problem
Solution: useCSS: "false"
Tip
You have
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
<script type="text/javascript" src="js/jquery.flexslider-min.js"></script>
But I think you need to include the flexslider js file before your function like this:
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery.flexslider-min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>

Categories

Resources