All Questions

1873
votes
74answers
891030 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...
1263
votes
47answers
1157319 views

What is the best way to detect a mobile device in jQuery?

Is there a solid 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 ha...
720
votes
18answers
441261 views

Selecting and manipulating CSS pseudo-elements such as ::before and ::after using 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: .spa...
1377
votes
49answers
830450 views

Convert form data to JavaScript object with jQuery

How do I convert all elements of my form to a JavaScript object? I'd like to have some way of automatically building a JavaScript object from my form, without having to loop over each element. I do ...
274
votes
29answers
122985 views

Accessing nested JavaScript objects with string key

I have a data structure like this : var someObject = { 'part1' : { 'name': 'Part 1', 'size': '20', 'qty' : '50' }, 'part2' : { 'name': 'Part 2', 's...
398
votes
8answers
364334 views

In jQuery, how to attach events to dynamic html elements?

Suppose I have some jQuery code that attaches an event handler to all elements with class "myclass". For example: $(function(){ $(".myclass").click( function() { // do something }); }...
899
votes
38answers
470042 views

Check if element is visible after scrolling

I'm loading elements via AJAX. Some of them are only visible if you scroll down the page. Is there any way I can know if an element is now in the visible part of the page?
684
votes
11answers
554955 views

jQuery/JavaScript: accessing contents of an iframe

I would like to manipulate the HTML inside an iframe using jQuery. I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like: $(...
411
votes
13answers
597101 views

jQuery AJAX cross domain

Here are two pages, test.php and testserver.php. test.php <script src="scripts/jq.js" type="text/javascript"></script> <script> $(function() { $.ajax({url:"testserver.p...
1566
votes
17answers
472708 views

Abort Ajax requests using jQuery

Using jQuery, how can I cancel/abort an Ajax request that I have not yet received the response from?

Previous Next