jquery not working on my device [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
i have this jquery code and html it is working on jsfiddle.com(http://jsfiddle.net/9rJev/) and this is the working example but when i get it to notepad++ its not working, and this is my code on notepad++
<html>
<head>
<script type="text/javascript" src="js/jquery.1.3.2.min.js" ></script>
<script type="text/javascript" src="js/jquery.1.6.4.min.js" ></script>
<script type="text/javascript" src="js/jquery-ui.min.js" ></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$('#movedown').ready(function(){
`$('#test').slideUp();`
})
$('#movedown').mouseover(function() {
$('#test').slideDown();
});
$('#movedown').mouseleave(function(){
$('#test').slideUp();
});
</script>
</head>
<body>
<div id="movedown">
<h4>yazan</h4>
<div id="test" style="background-color:lightgrey; border:2px solid grey;padding:10px;">Hello, this will slide down.</div>
</div>
</body>
</html>
but its not working on google chrome anyone have any idea what is the issu.
please help.and thanks

Change your JS to this:
$(document).ready(function(){
$('#movedown').ready(function(){
$('#test').slideUp();
})
$('#movedown').mouseover(function() {
$('#test').slideDown();
});
$('#movedown').mouseleave(function(){
$('#test').slideUp();
});
});
And also remove all but 1 jquery reference. Note you need to include the ready function, and you had some odd characters around $('#test').slideUp(); which caused JS errors. After these minor changes your code performed fine for me.

Related

Why does my simple script tag break the following script tag? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 months ago.
Improve this question
I am tearing my hair out over this. Why is foo() undefined when I click the button in this script?
<html>
<body>
<script type="text/javascript" src="./app2.js"/>
<script">
function foo() {
console.log('foo...');
}
</script>
<button type="button" onClick="foo()" id="testbutton">Click!</button>
<button type="button" onClick="hello()">Click hello!</button>
</body>
</html>
but not if I remove the first script tag?
<html>
<body>
<!-- <script type="text/javascript" src="./app2.js"/>-->
<script>
function foo() {
console.log('foo...');
}
</script>
<button type="button" onClick="foo()" id="testbutton">Click!</button>
</body>
</html>
My app2.js is just
function hello() {
console.log('hello');
}
I have tested in Chrome and Safari on macOS. The hello function works as expected.
Auto closing tags are used in React JSX and not in vanilla HTML
Replace
<script type="text/javascript" src="./app2.js"/>
with
<script type="text/javascript" src="./app2.js" ></script>

i tried loading html page to div using jQuery ajax [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 2 years ago.
Improve this question
trying to load html page to div using jQuery ajax im pretty sure it's right but i don't know why exactly it's not working.
that's my code:
<div class="second">
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("button").on("click",function(){
$('#second').load($(this).data("page"));
});
});
</script>
Consider the following code.
$(function() {
$("button").click(function() {
$(".second").load($(this).data("page"));
});
});
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<button data-page="page-2.html">Get Page 2</button>
<div class="second"></div>
This will work properly as it uses a Class selector to target he proper <div> element.
Change:
$('#second')
To:
$('.second')
As second is a class, not an id.

redirect using document ready does not work [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
here below is my code i can't seem to find what is wrong it is not redirecting to the link.
<html>
<head>
<script type="text/javascript" src="<?= baseurl(); ?>/public/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(function() { $("formRedirect").submit(); });
});
</script>
</head>
<body>
<form id='formRedirect' action="http://www.example.com/something/something.aspx" method="post"><input type="submit" name="redirect" value='<?= $token ?>'</form>
</body>
Try this:
<html>
<head>
<script type="text/javascript" src="<?= baseurl(); ?>/public/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#formRedirect").submit();
});
</script>
</head>
<body>
<form id='formRedirect' action="http://www.example.com/something/something.aspx" method="post"><input type="submit" name="redirect" value='<?= $token ?>'</form>
</body>
For id jquery detect them with #
Try like this
$("#formRedirect")[0].submit();
Use
$(document).ready(function() {});
or
$(function(){})
Both same
U have added $(function(){}); inside document.ready
$(function(){}); is similar to $(document).ready(function() {});
Use following code:
$(document).ready(function() {
$("#formRedirect").submit();
});
I find the Chrome console to be very helpful in debugging situations like this. I would start by making sure you are getting a result from your jQuery selector.
You can open the Chrome console by pressing F12
In the Chrome console, type $("formRedirect") and see if you get any results. You probably won't, since you are missing the # ID selector.
Next, try submitting your corrected jQuery object. If it doesn't work, try accessing the actual HTML object by adding in a [0] at the end of your selector, as suggested by #Anik.

Why is my jQuery not working? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I just finished the introductory course on Codecademy and I wanted to use it on a web project but I can't seem to get it working.
test.html
<html>
<head>
<title>jQuery</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="test.js"></script>
</head>
<body>
<p style="font-family: verdana;">wfef</p>
</body>
</html>
test.js
$(document).ready(function() {
$('p').click(function() {
$(this).hide();
};
});
You have a syntax error in your code. You've omitted a closing parenthesis. Try this:
$(document).ready(function() {
$('p').click(function() {
$(this).hide();
}); // added a ) here.
});
Use this :
$(document).ready(function() {
$('p').click(function() {
$(this).hide();
}); // Missed ')' to close click function
});
Once you correct your actual javascript as suggested in other posts, make sure that the browser can actually find your file, test.js. In chrome you can hit ctrl + shift + j and look at the console for errors and make sure that your file can actually be found. It should be in the same directory as your other html file.
$(document).ready(function() {
$('p').click(function() {
$(this).hide();
}); //Syntax error here! Required a ) brace to close your .click(function () {
});

javascript- function not defined error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have a html page with a button whos onclick calls a javascript function...but I have been getting a function not defined error for two days! Can someone help?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/jquery.mobile-1.2.1.css" />
<link rel="stylesheet" href="css/jqm-docs.css"/>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jqm-docs.js"></script>
<script src="js/jquery.mobile-1.2.1.js"></script>
<script>
function doSomething(){
alert('this is a test');
}
</script>
</head>
<body>
<div data-role="dialog">
<div data-role="content" id = "test" data-theme="c">
$confirm
Cancel
</div>
</div>
</body>
</html>
This might be handy:
http://jquerymobile.com/demos/1.2.0/docs/pages/page-scripting.html
You need to stick your scripts within the page element:
<div data-role="page">
<script>
function doSomething(){
alert('this is a test');
}
</script>
<!-- the rest of your stuff -->
</div>
In fact i have passed personally with this error even with valide HTML all what you need to do is move all of your functions to the head element.
Here is a fiddle:
http://jsfiddle.net/WekEA/1/
To demonstate what i have said in the framework & change the NoWrapToHead to onload

Categories

Resources