All Questions

1468
votes
19answers
592797 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...
313
votes
6answers
76284 views

Why does jQuery or a DOM method such as getElementById not find the element?

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 bind an e...
4532
votes
15answers
763099 views

"Thinking in AngularJS" if I have a jQuery background?

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...
2447
votes
25answers
1134276 views

How can I upload files asynchronously?

I would like to upload a file asynchronously with jQuery. This is my HTML: <span>File</span> <input type="file" id="file" name="file" size="10"/> <input id="uploadbutton" type="b...
1917
votes
16answers
467765 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...
7339
votes
59answers
4373119 views

How to redirect to another webpage?

How can I redirect the user from one page to another using jQuery or pure JavaScript?
2485
votes
9answers
693526 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. e...
518
votes
11answers
1028795 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> &l...
545
votes
20answers
954369 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: funct...
213
votes
6answers
75179 views

Using a variable for a key in a JavaScript object literal

Why does the following work? <something>.stop().animate( { 'top' : 10 }, 10 ); Whereas this doesn't work: var thetop = 'top'; <something>.stop().animate( { thetop : 10 }, 10 );...

Previous Next