Question: If I had two divs, both with id="myDiv", would `$("#myDiv").fadeOut();` fade both divs out? Or would it fade only the first/second? Or none at all?

How do I change which one it fades out?

**Note:** I know duplicate id's is against standards but I'm using the fancybox modal popup and it duplicates specified content on your page for the content of the popup. If anyone knows a way around this (maybe I'm using fancybox wrong) please let me know.

Answer: 
jQuery matches exactly one element when querying for an ID. An array of at most one `Element` object will be returned by `$("#foo").get()`. See the [jQuery documentation](http://docs.jquery.com/Selectors/id) for more information, or try it yourself.

```
$(function() {
    alert($("#foo").length);
});

```
I recently had a similar problem. I had a single page that displayed different content through an Ajax load. There is a button that triggers the server to generate a PDF image.

My original solution was to use a class selector, which worked fine, but caused friction with another developer. There were so many classes already in the links that using a class as an identifier made the code ugly. So I used a name attribute:

```
<a name="printButton"....

$('a[name="printButton"]').on('click',function(){....

```

Worked just dandy!