All Questions

1505
votes
19answers
603082 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...
322
votes
6answers
77462 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...
4530
votes
15answers
766733 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...
2478
votes
25answers
1142260 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...
1936
votes
16answers
474068 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...
7451
votes
60answers
4451939 views

How to redirect to another webpage?

How can I redirect the user from one page to another using jQuery or pure JavaScript?
2515
votes
9answers
700017 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...
521
votes
11answers
1041951 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...
553
votes
20answers
971824 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...
219
votes
6answers
76608 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