We want to concatenate the function name and variable name. This should occur on click of a &lt;a&gt; tag.   How can we concatenate the function and variable name?  Issue:   we are getting error message fn_dataId() is not defined   Desired output:  fn_dataId() should be fn_some123();  What we tried    $(function() {     $('.link').on('click', function() {       console.log('clicked');       var dataId = $(this).attr('data-id');       console.log('data id - ' + dataId);              // What we tried, but didn't work.        fn_dataId();      }); }); &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;a data-id="some123" class="link"&gt; Click here &lt;/a&gt;
5575
I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later?  Depending on the circumstances, I may need to pass various arguments into the method too.  Some of the functions may take the form of namespace.namespace.function(args[...]).
25453
I have created a 'control' using jQuery and used jQuery.extend to assist in making it as OO as possible.  During the initialisation of my control I wire up various click events like so  jQuery('#available input',              this.controlDiv).bind('click', this, this.availableCategoryClick);   Notice that I am pasing 'this' as the data argument in the bind method. I do this so that I can get at data attached to the control instance rather from the element that fires the click event.   This works perfectly, however i suspect there is a better way  Having used Prototype in the past, I remember a bind syntax that allowed you to control what the value of 'this' was in the event.  What is the jQuery way?
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.
23360
I want to use jQuery inside a firefox extension, I imported the library in the xul file like this:  &lt;script type="application/x-javascript" src="chrome://myExtension/content/jquery.js"&gt; &lt;/script&gt;   but the $() function is not recognized in the xul file neither do the jQuery().  I googled about the problem and found some solutions but no one did work with me:    I've also tried to pass the 'content.document' object(which refrences the 'document' object) as the context parameter to the jQuery function like this:  $('img',content.document);   but still not working, does any one came across this problem before?
67748
I have a simple html block like:  &lt;span id="replies"&gt;8&lt;/span&gt;   Using jquery I'm trying to add a 1 to the value (8).  var currentValue = $("#replies").text(); var newValue = currentValue + 1; $("replies").text(newValue);   What's happening is it is appearing like:  81  then  811  not 9, which would be the correct answer.  What am I doing wrong?
71962
I have an element with an onclick method.  I would like to activate that method (or: fake a click on this element) within another function.  Is this possible?
83873
Is it possible to do something like this?  var pattern = /some regex segment/ + /* comment here */     /another segment/;   Or do I have to use new RegExp() syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise.
15817
I have enum and use the variables like myEnum.SomeNameA, myEnum.SomeNameB, etc.  When I return one of these variables from a function, can I print their names (such as myEnum.SomeNameA) instead of the value they returned?
36511
I understand passing in a function to another function as a callback and having it execute, but I'm not understanding the best implementation to do that. I'm looking for a very basic example, like this:  var myCallBackExample = {     myFirstFunction : function( param1, param2, callback ) {         // Do something with param1 and param2.         if ( arguments.length == 3 ) {             // Execute callback function.             // What is the "best" way to do this?         }     },     mySecondFunction : function() {         myFirstFunction( false, true, function() {             // When this anonymous function is called, execute it.         });     } };   In myFirstFunction, if I do return new callback(), then it works and executes the anonymous function, but that doesn't seem like the correct approach to me.
72086
I'm refactoring some old JavaScript code and there's a lot of DOM manipulation going on.  var d = document; var odv = d.createElement("div"); odv.style.display = "none"; this.OuterDiv = odv;  var t = d.createElement("table"); t.cellSpacing = 0; t.className = "text"; odv.appendChild(t);   I would like to know if there is a better way to do this using jQuery. I've been experimenting with:  var odv = $.create("div"); $.append(odv); // And many more   But I'm not sure if this is any better.
51606
Possible Duplicate:          This is something I haven't quite figured out yet, but I have been using function(){}() just because my VIM syntax highlight screws up if I add the parenthesis, although I've seen (function(){})() around many times, maybe its an IE thing?  edit:  var singleton = function() {     // code }();  var singleton = (function() {     // code })();
27909
I was trying to concatenate text files in sub-folders and tried:  cat ./{mainfolder1,mainfolder2,mainfolder3}/{subfolder1}/book.txt &gt; out$var   However this did not return anything. So, tried adding a non existing 'subfolder2'  cat ./{mainfolder1,mainfolder2,mainfolder3}/{subfolder1,subfolder2}/book.txt &gt; out$var   And this time it did work out, concatenating the files successfully. Why does this happens?
46438
when i select the records in vf page ,after click on the VF Button the conga should be call along with id for generating the PDF but on button click the window is opening but showing error that "ID Parameter is missing" ? how to over come the issue? your reply will be appricated ,please reply asap.  vfpage:  &lt;apex:commandButton value="Generate Invoice" action="{!GenerateInvoice}"  onclick="openConga(setOfIds)" reRender="table1"/&gt;  &lt;script&gt; function openConga(setOfIds){   if(setOfIds !=Null){   var Formastring=setOfIds.splits(',');   var joinIds=Formastring.join("'|'");   var removeSpace=joinIds.replace(" ","");   var removeLeft=removeSpace.replace("[","");   var removeRight=removeLeft.replace("]","");   var finalSetIds=removeRight;    var CongaUrl ="/apex/APXTConga4__Conga_Composer?sessionId={!$API.Session_ID}" +"&amp;serverUrl={!$API.Partner_Server_URL_290}&amp;Id={!Payment_Id}" +"&amp;QVar1Id=[sql1221]a186C0000007yB3?pv1=" + finalSetIds +"&amp;TemplateId={QVar1}";  window.open(CongaUrl, "Conga","menubar=no,height=600,width=800");    } } &lt;/script&gt;   controller:  [‎28-‎01-‎2019 12:13]  Sakhare, Ankita:   public PageReference GenerateInvoice() {     selectedEsr = new List &lt; Payment__c &gt; ();     for (wrappayment wp: paymentList) {         if (wp.selected == true) {             Payment_Id = wp.pay.id;          }     }      return null; }
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).
66844
How do you combine two jQuery search results? eg:  var $allFoos = $('.foo'),     $allBars = $('.bar')     $allFoosAndBars = $allFoos + $allBars;   Obviously, I just made up that last line, but I hope it makes it sorta clear what I mean. To be clear, the example is greatly simplified, and it could be any arbitrary sets i'm talking about, so $('.foo, .bar') is not what I'm after.
20031
I'm following :   But in my real code, I've used google tag manager to manage google analytics. So I have just one script in the head of my website which belongs to gtm:  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-P8F58CT');  ga('create', 'UA-124402662-1', 'auto'); // Uncaught ReferenceError: ga is not defined   As you can see, I've added ga('create', 'UA-124402662-1', 'auto') right after that google tag manager (the same as the tutorial I've linked in the first line of my question). And I have a ga('send', 'pageview', newURL); code which will be executed when the page changes using ajax.  The problem is it throws: (as I've commented in code above)     Uncaught ReferenceError: ga is not defined   How can I fix it? Someone told me no need to add ga('create', 'UA-124402662-1', 'auto'); at all, and gtm will handle it all. But in my tests:   When I open my website (homepage), and run ga('send', 'pageview', "/adv"); in the console, nothing changes in google analytics and it still points to the homepage. When I open my website (homepage), and run ga('create', 'UA-124402662-1', 'auto'); and then run ga('send', 'pageview', "/adv");, then the google analytics will be changed to the /adv (not homepage anymore). So I believe ga('create', 'UA-124402662-1', 'auto'); is needed. But why it is undefined?
28108
If i do jQuery(expr).change( function), then I can get an event function to fire when the user makes a change to the value.  Is it possible to get this to fire if it's changed programatically, ie if I call jQuery(expr).val("moo").  or if some Plain old JavaScript changes it's value?  Thanks for any help.