I have something like this:  &lt;div id="container"&gt;&lt;/div&gt;   this is the html. Inside of the container, I add other div elements using jQuery.  $(document).ready(function () {     $.get("/Ask", {}, function (response, status) {         $.each(response.cars, function (index, val) {             $("#container").append("&lt;div class = 'q' id=" + val.id + "\"&gt;" + val.carName + "&lt;br&gt;" + val.date + "&lt;/div&gt;");         });     });      $("div").click(function (e) {         e.stopPropagation();         alert($(this).attr("id"));     }); });   On click, I want to retrieve the id from my inner divs (they are 1, 2, 3) but whenever I click on any of the divs added using jQuery, it shows container or nothing at all. How can I get the id from the recently added divs? Tried even with:  $(".q").click(function(){     alert($(this).attr("id")); });
112
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 and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
83170
I want to ask how to get id of element which was clicked by right clicking in open menu. I must know ID of this element to show only that history the element what was clicked fom open menu:
621
How to Handle Dynamic Changing IDs In XPath? for example :   //div[@id='post-body-3647323225296998740']/div[1]/form[1]/input[1]   In this xpath id "3647323225296998740" is changing every time when reloading the page.   Is there any way to handle this type of situation in Selenium?
117023
I have an HTML page with some textual spans marked up something like this:  ... &lt;span id="T2" class="Protein"&gt;p50&lt;/span&gt; ... &lt;span id="T3" class="Protein"&gt;p65&lt;/span&gt; ... &lt;span id="T34" ids="T2 T3" class="Positive_regulation"&gt;recruitment&lt;/span&gt; ...   I.e. each span has an ID and refers to zero or more spans via their IDs.  I would like to visualize these references as arrows.  Two questions:   How can I map an ID of a span to the screen coordinates of the rendering of the span? How do I draw arrows going from one rendering to another?   The solution should work in Firefox, working in other browsers is a plus but not really necessary. The solution could use jQuery, or some other lightweight JavaScript library.
80302
&lt;div id="myDiv"&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt;      &lt;a&gt;...&lt;/a&gt; &lt;/div&gt;   If you wanted to select the 2nd, 3rd and 4th a tags in the above example, how would you do that? The only thing I can think of is:  $("#myDiv a:eq(1), #myDiv a:eq(2), #myDiv a:eq(3)")   But that doesn't look to be very efficient or pretty. I guess you could also select ALL the as and then do run .each over them, but that could get very inefficient if there were a lot more as.
21250
I have a page where some event listeners are attached to input boxes and select boxes. Is there a way to find out which event listeners are observing a particular DOM node and for what event?  Events are attached using:    Event.observe; DOM's addEventListener; As element attribute element.onclick.
115970
Using a ajax request I want to change content of my div.  &lt;div id="d1"&gt;202&lt;/div&gt;   So I want to change the content to a different number.  $('d1').InnerText???   Also, say I wanted to increment the number, how could I do that? Do I have to convert to int?
59846
In the following example code, I attach an onclick event handler to the span containing the text "foo". The handler is an anonymous function that pops up an alert().  However, if I assign to the parent node's innerHTML, this onclick event handler gets destroyed - clicking "foo" fails to pop up the alert box.  Is this fixable?  &lt;html&gt;  &lt;head&gt;  &lt;script type="text/javascript"&gt;    function start () {     myspan = document.getElementById("myspan");     myspan.onclick = function() { alert ("hi"); };      mydiv = document.getElementById("mydiv");     mydiv.innerHTML += "bar";   }   &lt;/script&gt;  &lt;/head&gt;   &lt;body onload="start()"&gt;    &lt;div id="mydiv" style="border: solid red 2px"&gt;      &lt;span id="myspan"&gt;foo&lt;/span&gt;    &lt;/div&gt;  &lt;/body&gt;  &lt;/html&gt;
92276
I have a form that is dynamically generated, and has dynamically generated id's (and potentially classes). The forms are the same but they have the related id tacked on to the end.  How can I select each set of inputs and apply code to each one?  I was experimenting with $('input[id^=@id_airline_for_]') but could not get it to fly. I suspect I am missing some fundamental jQuery knowledge that is holding me back since I am sure this is a common problem with dynamic forms.   &lt;form method='POST'&gt;     &lt;label for="id_airline_for_8"&gt;Airline&lt;/label&gt;:     &lt;input id="id_airline_for_8" class="arrival_transfer_toggle_8" type="text" maxlength="30" name="airline_for_8"/&gt;     &lt;label for="id_flight_number_for_8"&gt;Flight Number&lt;/label&gt;:     &lt;input id="id_flight_number_for_8" class="arrival_transfer_toggle_8" type="text" maxlength="30" name="flight_number_for_8"/&gt;      &lt;label for="id_airline_for_17"&gt;Airline&lt;/label&gt;:     &lt;input id="id_airline_for_17" class="arrival_transfer_toggle_17" type="text" maxlength="30" name="airline_for_17"/&gt;     &lt;label for="id_flight_number_for_17"&gt;Flight Number&lt;/label&gt;:     &lt;input id="id_flight_number_for_17" class="arrival_transfer_toggle_17" type="text" maxlength="30" name="flight_number_for_17"/&gt;      -- snip --  &lt;/form&gt;   EDIT: I should update that i want to be able to perform some action when the input is clicked but only for classes with a matching id at the end.  To make it easy, lets say I want all inputs with a matching id at the end of the #id to disappear when one is clicked (just for arguments sake).
98687
If the user selects an option in a dropdown box, there must be added a label and a textbox. Using appendChild, these elements get added to the end of the container.  var newFreeformLabel = document.createElement('label'); newFreeformLabel.innerHTML = 'Omschrijving:';  var newFreeformField = document.createElement('input'); newFreeformField.className = 'textfield'; newFreeformField.name = 'factuur_orderregel[]';  var newFreeformSpacer = document.createElement('div'); newFreeformSpacer.className = 'spacer';  container.appendChild(newFreeformLabel); container.appendChild(newFreeformField); container.appendChild(newFreeformSpacer);   The issue is that these elements should be inserted at the beginning of container, not at the end.  Is there a solution to this in PrototypeJS?
9151
How can I check the existence of an element in jQuery?  The current code that I have is this:  if ($(selector).length &gt; 0) {     // Do something }   Is there a more elegant way to approach this? Perhaps a plugin or a function?
105678
My code looks like this:  &lt;ul id="ulList"&gt;   &lt;li class="listClass" id="id1"&gt;&lt;a href="http://link1"&gt;Link 1&lt;/a&gt;&lt;/li&gt;   &lt;li class="listClass" id="id2"&gt;&lt;a href="http://link2"&gt;Link 2&lt;/a&gt;&lt;/li&gt;   &lt;li class="listClass" id="id3"&gt;&lt;a href="http://link3"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;   Now I like to get the following:  All links as an array  All ids of li as an array  Can someone help me please?
107057
I have an object, and I want to list all the selectors to which it responds. It feels like this should be perfectly possible, but I'm having trouble finding the APIs.
57540
I'm trying to update an account list and I need to get the Ids when the update fails.  I use the getId() method but for accounts which fail I get null.  It's an update so my account already has an Id.  Is it normal ? If it is, how can I get the Ids list of non-updated accounts ?  Here is my code :  List&lt;Account&gt; accountsList = [select Id from Account];  for(Account a : accountsList) {     a.Name = 'Test', }  List&lt;Database.SaveResult&gt; res = Database.update(accountsList, false);  for (Database.SaveResult s : res) {     if (!s.isSuccess()) {         system.debug(s.getId()); // I get null here      }  }
116497
Let me describe the problem in details:  I want to show an absolute positioned div when hovering over an element. That's really simple with jQuery and works just fine. But when the mouse goes over one of the child elements, it triggers the mouseout event of the containing div. How do I keep javascript from triggering the mouseout event of the containing element when hovering a child element.   What's the best and shortest way to do that with jQuery?  Here is a simplified example to illustrate what I mean:  Html:  &lt;a&gt;Hover Me&lt;/a&gt; &lt;div&gt;   &lt;input&gt;Test&lt;/input&gt;   &lt;select&gt;     &lt;option&gt;Option 1&lt;/option&gt;     &lt;option&gt;Option 2&lt;/option&gt;   &lt;/select&gt; &lt;/div&gt;   Javascript/jQuery:  $('a').hover( function() { $(this).next().show() }               function() { $(this).next().hide() } );
30976
It looks like if I load dynamic content using $.get(), the result is cached in browser.  Adding some random string in QueryString seems to solve this issue (I use new Date().toString()), but this feels like a hack.   Is there any other way to achieve this? Or, if unique string is the only way to achieve this, any suggestions other than new Date()?
23400
How do I remove items from, or add items to, a select box? I'm running jQuery, should that make the task easier. Below is an example select box.  &lt;select name="selectBox" id="selectBox"&gt;     &lt;option value="option1"&gt;option1&lt;/option&gt;     &lt;option value="option2"&gt;option2&lt;/option&gt;     &lt;option value="option3"&gt;option3&lt;/option&gt;     &lt;option value="option4"&gt;option4&lt;/option&gt;     &lt;/select&gt;