I have this div that I am fetching from a database  '&lt;div class="column"&gt;'+          '&lt;div&gt;'+ '&lt;img src='+aparat.imagine+' width="150" height="140" /&gt;' +'&lt;/div&gt;'+          '&lt;div&gt;'+ aparat.nume + '&lt;/div&gt;' +                                                   //functia care le aranjeaza          '&lt;div id="pret"&gt;'+ aparat.pret +'&amp;nbsplei' + '&lt;/div&gt;'+          '&lt;div&gt;'+'&lt;button data-value="'+aparat.id+'" class = "comanda"&gt;'+'Comanda!'+'&lt;/button&gt;'+'&lt;/div&gt;'          + '&lt;/div&gt;';   and the event handler:  $(document).ready(function(){ $('.comanda').click( function() {         alert('button clicked');         }); });   The problem is, when I click the button nothing happens, what am I doing wrong?
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.
17427
I'm porting a module that currently works with Blocks/BlockForms to Paragraphs/NodeForms. I'm inserting an embedded form inside a Paragraph inside a Node Edit page using a hook_field_widget_entity_reference_paragraphs_form_alter. The general structure where the form gets inserted is: $form['field']['widget'][0]['settings'][form here]  After this the form displays as expected on the node edit page. The inserted form goes through a number of #process steps. The element in question is a select form that when the button underneath it is pressed, is supposed to retrieve some data via a custom submit handler and place it on the page with ajax:  The array for this element looks like this:  You can see the custom submit handler that is supposed to fire when 'Select Segment Set' is pressed After debugging, I've found that the entire NodeForm appears to be submitted to the backend, and the only handler that is found is from some other field that uses ajax. In short 'updateSegmentSet' is never discovered as a submit handler. When I debug the original module based on block/blockforms, I do see the correct submit handler being discovered. Now in the latter case, of course a blockForm is submitted to the back end with the correct plugin. Given that this is basically a form within a form within a form, is there something special I have to do to get the custom submit handler to run? I've read a few things online e.g. the 'settings' key and '#tree' = true. EDIT The Ajax property looks like this:       '#ajax' =&gt; [         'callback' =&gt; [$this, 'updateSegmentSetAjax'],         'wrapper' =&gt; $wrapper_id,       ],    public function updateSegmentSetAjax(array &amp;$form, FormStateInterface $form_state) {     $button = $form_state-&gt;getTriggeringElement();     // Go one level up in the form, to the widgets container.     return NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -2));   }  As best I can tell, this is never called either.
39221
So, I can create an input button with an image using &lt;INPUT type=&quot;image&quot; src=&quot;/images/Btn.PNG&quot; value=&quot;&quot;&gt;  But, I can't get the same behavior using CSS. For instance, I've tried &lt;INPUT type=&quot;image&quot; class=&quot;myButton&quot; value=&quot;&quot;&gt;  where &quot;myButton&quot; is defined in the CSS file as .myButton {     background:url(/images/Btn.PNG) no-repeat;     cursor:pointer;     width: 200px;     height: 100px;     border: none; }  If that's all I wanted to do, I could use the original style, but I want to change the button's appearance on hover (using a myButton:hover class). I know the links are good, because I've been able to load them for a background image for other parts of the page (just as a check). I found examples on the web of how to do it using JavaScript, but I'm looking for a CSS solution. I'm using Firefox 3.0.3 if that makes a difference.
49395
In jQuery when you do this:  $(function() {    alert("DOM is loaded, but images not necessarily all loaded"); });   It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obviously what we want if we're initializing any DOM stuff such as showing or hiding elements or attaching events.  Let's say though that I want some animation and I don't want it running until all the images are loaded. Is there an official way in jQuery to do this?  The best way I have is to use &lt;body onload="finished()"&gt;, but I don't really want to do that unless I have to.  Note: There is a  in Internet Explorer which actually does wait for all images to load before executing code inside $function() { }. So if you're using that platform you'll get the behavior I'm looking for instead of the correct behavior described above.
67914
I am creating an element with document.createElement(). Now how can I pass it to a function that only takes a Jquery object?  $("#id")    I can not use it, as the element has not been rendered in the page yet.
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?
29285
What's the difference between &lt;div class=""&gt; and &lt;div id=""&gt; when it comes to CSS? Is it alright to use &lt;div id=""&gt;?  I see different developers doing this in both ways, and since I'm self taught, I've never really figured it out.
56974
I want to create a toggle button in html using css. I want it so that when you click on it  , it stays pushed in and than when you click it on it again it pops out.   If theres no way of doing it just using css. Is there a way to do it using jQuery?
32471
What's the simplest way to add a click event handler to a canvas element that will return the x and y coordinates of the click (relative to the canvas element)?  No legacy browser compatibility required, Safari, Opera and Firefox will do.
34496
I have the following html code:   &lt;h3 id="headerid"&gt;&lt;span onclick="expandCollapse('headerid')"&gt;&amp;uArr;&lt;/span&gt;Header title&lt;/h3&gt;   I would like to toggle between up arrow and down arrow each time the user clicks the span tag.   function expandCollapse(id) {        var arrow = $("#"+id+" span").html(); // I have tried with .text() too     if(arrow == "&amp;dArr;") {              $("#"+id+" span").html("&amp;uArr;");                    } else {                 $("#"+id+" span").html("&amp;dArr;");                    } }   My function is going always the else path. If I make a javacript:alert of arrow variable I am getting the html entity represented as an arrow. How can I tell jQuery to interpret the  arrow variable as a string and not as html.
87646
Salesforce has functions that do a lot of basic web app functionality for you, called Event Reference. They can be found here   On the editRecord Event Reference, found here   essentaily, I create a   &lt;ui:button label="Edit" press="{!c.editRecord}"/&gt;   on my component, reference the attribute on the page and add the function from the docs in the controller  editRecord : function(component, event, helper) {     var editRecordEvent = $A.get("e.force:editRecord");      console.log("record id is: " + component.get("v.item.Id"));     console.log("editRecordEvent value is: " + editRecordEvent);      editRecordEvent.setParams({         "recordId": component.get("v.item.Id")     });      editRecordEvent.fire(); }   correct?  Here is the odd thing. From the console.logs, I get the record id, but the editRecordEvent returns undefined. What is going on? Is there something I need to reference in my component to use Event Reference?
5844
I have an input type="image". This acts like the cell notes in Microsoft Excel. If someone enters a number into the text box that this input-image is paired with, I setup an event handler for the input-image. Then when the user clicks the image, they get a little popup to add some notes to the data.  My problem is that when a user enters a zero into the text box, I need to disable the input-image's event handler. I have tried the following, but to no avail.  $('#myimage').click(function { return false; });
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?
16631
Is there any way to get the ID of the element that fires an event?  I'm thinking something like:    $(document).ready(function() {   $("a").click(function() {     var test = caller.id;     alert(test.val());   }); }); &lt;script type="text/javascript" src="starterkit/jquery.js"&gt;&lt;/script&gt;  &lt;form class="item" id="aaa"&gt;   &lt;input class="title"&gt;&lt;/input&gt; &lt;/form&gt; &lt;form class="item" id="bbb"&gt;   &lt;input class="title"&gt;&lt;/input&gt; &lt;/form&gt;     Except of course that the var test should contain the id "aaa", if the event is fired from the first form, and "bbb", if the event is fired from the second form.
70655
I am trying to handle Application event in a listening component but it doesn't work for some reason. Please, help. I can't write in console log "here" in the end   Application  &lt;aura:application extends="force:slds" access="global"&gt;     &lt;c:SearchCmp/&gt;     &lt;c:DisplaySearchResultCmp/&gt;    &lt;/aura:application&gt;   Search Component  &lt;aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" &gt;     &lt;aura:registerEvent name="searchEvt" type="c:SearchEvent" /&gt;     &lt;aura:attribute name="inputSearch" type="String"/&gt;     &lt;div&gt;         &lt;lightning:input label="Search for books and writers:" value="{!v.inputSearch}"/&gt;     &lt;/div&gt;     &lt;lightning:button         label="Search"         onclick="{!c.getInput}" /&gt; &lt;/aura:component&gt;      Search Component Controller  getInput : function(component, event, helper) {     helper.fireAppAction(component, event); }   Search Component Helper  fireAppAction : function(component, event) {         var appEvent = $A.get("e.c:SearchEvent");         appEvent.setParams({             "searchQuery": component.get("v.inputSearch")             });         appEvent.fire();     }   Result Component  &lt;aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"  access="global" controller="SearchCmpController"&gt;      &lt;aura:handler name="showResultList" event="c:SearchEvent" action="{!c.searchData}"/&gt;     &lt;aura:attribute name="resultWrappers" type="SearchCmpController.BookWriterWrapper[]"/&gt;     &lt;aura:attribute name="isEmptyResult" type="Boolean" default="true"/&gt;      &lt;div&gt;         &lt;div class="{!v.IsEmptyResult ? 'disp' : 'slds-hide'}"&gt;Results&lt;/div&gt;         &lt;div class="{!v.IsEmptyResult ? 'slds-hide' : 'disp'}"&gt;No Results&lt;/div&gt;     &lt;/div&gt;  &lt;/aura:component&gt;   Result Component Controller  searchData : function(component, event, helper) {         console.log("here");         component.set("v.resultWrappers", true);     }   Event "SearchEvent"  &lt;aura:event type="APPLICATION"&gt;     &lt;aura:attribute name="searchQuery" type="String"/&gt; &lt;/aura:event&gt;
67655
Does anyone know how to select an item in the DOM by ID with jQuery, when that ID has a space?   For example, the ID of my item would be  &lt;div id="content Module"&gt;Stuff&lt;/div&gt;   How would I select this with jQuery?   If I just do   $("#content Module").whatever()    jQuery will try to find an item with both the ID of content and the ID of Module, which is not what I am looking for.  I should add that I am working with an old code base where these two word ids are used extensively, so going through and changing all the IDs would be bad.
77655
I'm looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like 'click' etc, but I'm building a tiny javascript library/plugin to handle some preview functionality.  I've got a script running to update some text in a dom element from a set of rules and data/user input I got, but now I need that same text shown in other elements that this script can't possibly know of. What I need is a good pattern to somehow observe this script producing the needed text.  So how do I do this? Did I overlook some builtin functionality in jquery to raise/handle user events or do I need some jquery plugin to do it? What do you think is the best way/plugin to handle this?