I want to pick all the elements inside the ul tag and push it in an array using javascript.How should I do that?  &lt;ul id="sortable1" class="connectedSortable"&gt; &lt;li class="ui-state-default"&gt;Item 1&lt;/li&gt; &lt;li class="ui-state-default"&gt;Item 2&lt;/li&gt; &lt;li class="ui-state-default"&gt;Item 3&lt;/li&gt; &lt;li class="ui-state-default"&gt;Item 4&lt;/li&gt; &lt;li class="ui-state-default"&gt;Item 5&lt;/li&gt; &lt;/ul&gt;
122776
I have a structure like this:  &lt;ul&gt;   &lt;li&gt;text1&lt;/li&gt;   &lt;li&gt;text2&lt;/li&gt;   &lt;li&gt;text3&lt;/li&gt; &lt;/ul&gt;   How do I use javascript or jQuery to get the text as an array?  ['text1', 'text2', 'text3']   My plan after this is to assemble it into a string, probably using .join(', '), and get it in a format like this:  '"text1", "text2", "text3"'
34827
I would like to find out, in JavaScript, which element currently has focus. I've been looking through the DOM and haven't found what I need, yet. Is there a way to do this, and how?  The reason I was looking for this:  I'm trying to make keys like the arrows and enter navigate through a table of input elements. Tab works now, but enter, and arrows do not by default it seems. I've got the key handling part set up but now I need to figure out how to move the focus over in the event handling functions.
75403
I have an array:  data.Dealer.car[0] data.Dealer.car[1] data.Dealer.car[2]   If I do this:  alert(data.Dealer.car.length); delete data.Dealer.car[1]; alert(data.Dealer.car.length);   It gives me the same count each time. Does the removed element still exist?
93369
I'm trying to figure out how to make a function that can take an array as a parameter and sort it. I think it is done with positional variables, but I'm not sure.
87065
I'm looking for some sample code that will sort the list items in an HTML list by alphabetical order.  Can anyone help?  Here is a sample list for people to work with:  &lt;ul class="alphaList"&gt;     &lt;li&gt;apples&lt;/li&gt;     &lt;li&gt;cats&lt;/li&gt;     &lt;li&gt;bears&lt;/li&gt; &lt;/ul&gt;
46205
I am looking for a good example implementation of a JavaScript/HTML AutoSuggest input box to get me started. What I am trying to implement will behave "Exactly" like the Tags input box here on stackoverflow.   If it helps I am using jQuery to perform Ajax request.   I am finding examples to help me implement this however I am concerned what about best practices in the area and would love to get opinions also.
98955
Suppose I have this code: var myArray = new Object(); myArray[&quot;firstname&quot;] = &quot;Bob&quot;; myArray[&quot;lastname&quot;] = &quot;Smith&quot;; myArray[&quot;age&quot;] = 25;  Now if I wanted to remove &quot;lastname&quot;?....is there some equivalent of myArray[&quot;lastname&quot;].remove()? (I need the element gone because the number of elements is important and I want to keep things clean.)
98146
Every time I toggle active class in a list (to dynamically change DOM content) I find that I always go to this approach to check and clear which class is active. I'm still fairly new to using pure javascript so I'm wondering if there is a better, simpler approach?  It feels like having to run a second function to clear out all active classes seems grunty.   I've included an example of how I do it.    var specialNav = document.getElementById("special-nav");  if (specialNav) {   var navItems = specialNav.getElementsByTagName('li');   var i;   for (i = 0; i &lt; navItems.length; i++) {     navItems[i].addEventListener("click", function() {       if (!this.classList.contains('active')) {         clearActives(navItems);         this.classList.toggle('active');       }     });   } }  function clearActives(classlist) {   if (classlist) {     for (i = 0; i &lt; classlist.length; i++) {       classlist[i].classList.remove('active');     }   } } .active {   color: red }  li {   cursor: pointer; } &lt;div id="special-nav"&gt;   &lt;ul&gt;     &lt;li class="active"&gt; 1&lt;/li&gt;     &lt;li&gt;2&lt;/li&gt;     &lt;li&gt;3&lt;/li&gt;     &lt;li&gt;4&lt;/li&gt;   &lt;/ul&gt; &lt;/div&gt;
104040
&lt;div aria-hidden="false" aura:id="newClientSectionId" role="dialog" class="slds-modal slds-modal--large slds-fade-in-open slds-hide"       style="width: 60%; margin: auto; "&gt;     &lt;div class="slds-m-bottom--xx-large"&gt;&lt;/div&gt;     &lt;div class="slds-modal__container"&gt;         &lt;div class="slds-modal__header"&gt;             &lt;button class="slds-button slds-button--icon-inverse slds-modal__close" onclick="{!c.showModalBox}"&gt;                 &lt;span class="slds-assistive-text"&gt;Close&lt;/span&gt;             &lt;/button&gt;             &lt;h2 class="slds-text-heading--medium"&gt;Create Opportunity&lt;/h2&gt;         &lt;/div&gt;         &lt;div class="slds-modal__content slds-p-around--medium"&gt;             &lt;div class="slds-m-top--xx-large"&gt;&lt;/div&gt;         &lt;/div&gt;         &lt;div class="slds-modal__footer"&gt; &lt;button class="slds-button slds-button--neutral" onclick="{!c.showModalBox}"&gt;Cancel&lt;/button&gt;             &lt;ui:button class="slds-button slds-button--brand" press="{!c.saveOpportunity}" label="Save" /&gt;         &lt;/div&gt;     &lt;/div&gt; &lt;/div&gt;  &lt;div class="slds-backdrop slds-backdrop--open slds-hide" id="backGroundSectionId"&gt;&lt;/div&gt;   Controller  //for showing modal $A.util.removeClass(component.find("newClientSectionId"), "slds-hide"); $A.util.removeClass(component.find("backGroundSectionId"), "slds-hide");   CSS  .THIS.slds-hide {    display:none; }
109703
How do I get a collection of the tags I've marked as favorites?  When I hover over a tag, and click the star icon, it toggles between Favorite, Normal and Ignored. How do I find that information using the data explorer?  If not possible, I would like to add such functionality please.  Example: On the web UI, I can go to the 'unanswered questions', then select 'my tags'. I want to filter and sort that list of questions.
56399
I have 2 components. VariationComponent and PGP_Tab_bar_item. I create PGP_Tab_bar_item in the markup of VariationComponent . Want to perform some action on PGP_Tab_bar_item if event is fired from PGP_Tab_bar_item component.  I am using component.find({instancesOf:}) but it is giving an empty Array[].  VariationComponent :  &lt;aura:attribute name="projects" type="Project__c[]" /&gt;  &lt;ul class="slds-tabs--default__nav" role="tablist"&gt; &lt;aura:iteration items="{!v.projects}" var="project" indexVar="index"&gt;     &lt;c:PGP_Tab_bar_item project="{!project}" isProgramme="false" variationId="{!v.variationId}" active="false"/&gt; &lt;/aura:iteration&gt; &lt;/ul&gt;  &lt;ui:button label="Save" press="{!c.handlePGPTab}" class="slds-button slds-button--brand" aura:id="handle" /&gt;   Controller:  handlePGPTabEvent : function(component, event, helper){     var tabs = component.find({ instancesOf : "c:PGP_Tab_bar_item" }) ;     console.log(tabs); // output Array[] in console }
23463
I need a quick algorithm to select 5 random elements from a generic list. For example, I'd like to get 5 random elements from a List&lt;string&gt;.
94400
This question was posted using the Android App.  When posting questions using the Android application, tag selection can be a little tricky &amp; error-prone.  The web application provides an autocompletion list of suggestions as you type, but no such list appears in the Android app. It would be very useful if similar functionality could be implemented there.  Also it appears that entering a new tag is friction-free, as might happen when fat fingering a tag. As a demonstration I have tagged this question with a false tag.  It should not be this easy to create a new tag, as I would guess the majority of these cases would be mistakes.
123532
I have a requirement to create a Lightning component that contains a ui:inputselect tag which will automatically fetch out its options from a custom pick list of an Object. How can this be achieved?
13314
I'm looking for a way to insert a &lt;style&gt; tag into an HTML page with JavaScript.  The best way I found so far:  var divNode = document.createElement("div"); divNode.innerHTML = "&lt;br&gt;&lt;style&gt;h1 { background: red; }&lt;/style&gt;"; document.body.appendChild(divNode);   This works in Firefox, Opera and Internet Explorer but not in Google Chrome. Also it's a bit ugly with the &lt;br&gt; in front for IE.  Does anyone know of a way to create a &lt;style&gt; tag that   Is nicer Works with Chrome?   Or maybe   This is a non-standard thing I should avoid Three working browsers are great and who uses Chrome anyway?
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).
48999
What is the way to refer index variable inside looping ?  The code below results in error:     Failed to save undefined: expecting a positive integer, found 'indx'   at column 10 of expression: v.labels[indx]: Source       &lt;aura:iteration var="item" items="{!v.items}" indexVar="indx"&gt;         &lt;li&gt;             &lt;label class="card-detail-label"&gt;{!v.labels[indx]}&lt;/label&gt;             &lt;span class="card-detail-value"&gt;{!item}&lt;/span&gt;           &lt;/li&gt;     &lt;/aura:iteration&gt;