Questions tagged [jquery]
jQuery is a JavaScript library. jQuery is a popular cross-browser JavaScript library that facilitates Document Object Model (DOM) traversal, event handling, animations, and AJAX interactions by minimizing the discrepancies across browsers. A question tagged jQuery should be related to jQuery, so jQuery should be used by the code in question, and at least jQuery usage-related elements must be in the question. Consider also adding the JavaScript tag.
jquery
79,244
questions
1674
votes
23
answers
1.1m
views
Event binding on dynamically created elements?
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.
This happens on page ready ...
610
votes
7
answers
202k
views
Why does jQuery or a DOM method such as getElementById not find the element if I put the script element near the top of the page?
What are the possible reasons for document.getElementById, $("#id") or any other DOM method / jQuery selector not finding the elements?
Example problems include:
jQuery silently failing to ...
3325
votes
16
answers
6.4m
views
Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?
Mod note: This question is about why XMLHttpRequest/fetch/etc. on the browser are subject to the Same Access Policy restrictions (you get errors mentioning CORB or CORS) while Postman is not. This ...
4502
votes
15
answers
855k
views
"Thinking in AngularJS" if I have a jQuery background? [closed]
Suppose I'm familiar with developing client-side applications in jQuery, but now I'd like to start using AngularJS. Can you describe the paradigm shift that is necessary? Here are a few questions that ...
3148
votes
34
answers
1.5m
views
How can I upload files asynchronously with jQuery?
I would like to upload a file asynchronously with jQuery.
$(document).ready(function () {
$("#uploadbutton").click(function () {
var filename = $("#file").val();
$.ajax({...
7698
votes
58
answers
7.9m
views
How do I redirect to another webpage?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
2502
votes
18
answers
733k
views
.prop() vs .attr()
So jQuery 1.6 has the new function prop().
$(selector).click(function(){
//instead of:
this.getAttribute('style');
//do i use:
$(this).prop('style');
//or:
$(this).attr('style'...
870
votes
27
answers
1.8m
views
jQuery Ajax File Upload
Can I use the following jQuery code to perform file upload using POST method of an ajax request ?
$.ajax({
type: "POST",
timeout: 50000,
url: url,
data: dataString,
success: ...
1151
votes
28
answers
902k
views
Selecting and manipulating CSS pseudo-elements such as ::before and ::after using javascript (or jQuery)
Is there any way to select/manipulate CSS pseudo-elements such as ::before and ::after (and the old version with one semi-colon) using jQuery?
For example, my stylesheet has the following rule:
.span::...
758
votes
17
answers
1.8m
views
jQuery Ajax POST example with PHP
I am trying to send data from a form to a database. Here is the form I am using:
<form name="foo" action="form.php" method="POST" id="foo">
<label for="bar">A bar</label>
&...
3253
votes
14
answers
940k
views
event.preventDefault() vs. return false
When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I'll use jQuery in the examples, but this applies to plain-JS as well:
1. ...
2950
votes
91
answers
1.8m
views
How do I detect a click outside an element?
I have some HTML menus, which I show completely when a user clicks on the head of these menus. I would like to hide these elements when the user clicks outside the menus' area.
Is something like this ...
1949
votes
66
answers
2.0m
views
How to detect a mobile device using jQuery
Is there a way to detect whether or not a user is using a mobile device in jQuery? Something similar to the CSS @media attribute? I would like to run a different script if the browser is on a handheld ...
2447
votes
54
answers
3.2m
views
Remove duplicate values from JS array
I have a very simple JavaScript array that may or may not contain duplicates.
var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy",&...
468
votes
5
answers
364k
views
Is there a JavaScript / jQuery DOM change listener?
Essentially I want to have a script execute when the contents of a DIV change. Since the scripts are separate (content script in the Chrome extension & webpage script), I need a way simply observe ...