jQuery .append DOM update I have a page where users can add their scripts to a form and then submit them. I'm using .append() to allow users to add new scripts if required, however when a new script is added the character count for that script no longer works, even though the HTML is identical (besides IDs). Is there a way to update the DOM so it will also recognise these new divs?  Here is an exmaple:    var $scriptNumber = 2; $('.script').keyup(charCount); $('#new-script').click(addScript);  function charCount() {  var $chars = $(this).val().length;  $(this).siblings('.char-count').html($chars + ' Characters'); }  function addScript() {  $('#scripts').append('&lt;div id="script-' + $scriptNumber + '-wrap" class="script-wrap"&gt;&lt;label for="script-1"&gt;Script ' + $scriptNumber + '&lt;/label&gt;&lt;textarea id="script-' + $scriptNumber + '" class="script" cols="40" rows="3"&gt;&lt;/textarea&gt;&lt;span class="char-count"&gt;0 Characters&lt;/span&gt;&lt;/div&gt;');   $scriptNumber++; } #scripts {   padding: 12px; } .script-wrap {   margin-bottom: 12px; } label {   font-weight: bold; } textarea {   width: 100%; } #new-script {   margin-left: 12px;   padding: 4px 12px;   background: purple;   color: white;   cursor: pointer; } #new-script:hover {   background: blue; } &lt;div id="scripts"&gt;   &lt;div id="script-1-wrap" class="script-wrap"&gt;     &lt;label for="script-1"&gt;Script 1&lt;/label&gt;     &lt;textarea id="script-1" class="script" cols="40" rows="3"&gt;&lt;/textarea&gt;     &lt;span class="char-count"&gt;0 Characters&lt;/span&gt;   &lt;/div&gt; &lt;/div&gt; &lt;span id="new-script"&gt;New Script&lt;/span&gt;
Event binding on dynamically created elements? 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.
What to do with random effects correlation that equals 1 or -1? Not so uncommon occurrence when dealing with complex maximal mixed models (estimating all possible random effects for given data and model) is perfect (+1 or -1) or nearly perfect correlation among some random effects. For the purpose of the discussion, let's observe the following model and model summary   Model: Y ~ X*Cond + (X*Cond|subj)  # Y = logit variable   # X = continuous variable   # Condition = values A and B, dummy coded; the design is repeated  #             so all participants go through both Conditions   # subject = random effects for different subjects    Random effects:  Groups  Name             Variance Std.Dev. Corr               subject (Intercept)      0.85052  0.9222                              X                0.08427  0.2903   -1.00                      CondB            0.54367  0.7373   -0.37  0.37                X:CondB          0.14812  0.3849    0.26 -0.26 -0.56 Number of obs: 39401, groups:  subject, 219  Fixed effects:                  Estimate Std. Error z value Pr(&gt;|z|)     (Intercept)       2.49686    0.06909   36.14  &lt; 2e-16 *** X                -1.03854    0.03812  -27.24  &lt; 2e-16 *** CondB            -0.19707    0.06382   -3.09  0.00202 **  X:CondB           0.22809    0.05356    4.26 2.06e-05 ***   The supposed reason behind these perfect correlations is that we have created a model which is too complex for the data that we have. The common advice that is given in these situations is (e.g., Matuschek et al., 2017; ) to fix the overparameterized coefficients to 0, because such degenerate models tend to lower the power. If we observe a marked change in fixed effects in a reduced model, we should accept that one; if there is no change, then there is no problem in accepting the original one.  However, let's presume that we are not interested only in fixed effects controlled for RE (random effects), but also in the RE structure. In the given case, it would be theoretically sound to assume that Intercept and the slope X have non-zero negative correlation. Several questions follow:   What to do in such situations? Should we report the perfect correlation and say that our data is not "good enough" to estimate the "real" correlation? Or should we report the 0 correlation model? Or should we maybe try to set some other correlation to 0 in hope that the "important" one will not be perfect anymore? I don't think there are any 100% correct answers here, I would mostly like to hear your opinions. How to write the code which fixes the correlation of 2 specific random effects to 0, without influencing the correlations between other parameters? Parsing domain from a URL I need to build a function which parses the domain from a URL.  So, with   http://google.com/dhasjkdas/sadsdds/sdda/sdads.html   or  http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html  it should return google.com  with   http://google.co.uk/dhasjkdas/sadsdds/sdda/sdads.html  it should return google.co.uk. How to typeset a primed vector I write a vector with an arrow above the letter using \vec{p} and sometimes the vector needs to be primed using ' (or ^{\prime}, equivalently).  However, neither  \vec{p}'     nor  \vec{p'}     looks satisfactory (first option: prime dash overlaps with vector arrow, second option: arrow looks misplaced).  How would one write a primed vector? What is the reason that the value "47" is so popular in electrical engineering? Let $D \subset \mathbb{C}$ be an open, connected set and let $\{ u_n \}$ be a sequence of harmonic functions with $u_n: D \longrightarrow (0, \infty)$. Show that if $u_n(z_0) \rightarrow 0$ for some $z_0 \in D$, then $u_n \rightarrow 0$ uniformly on compact subsets of $D$.  If you could offer a hint or a helpful question to get me started I'd appreciate it.   Progress: I now see why showing it for the unit disk suffices (any compact subset in $D$ can be covered by finitely many disks each which is contained in $D$). TL2018 (MacTeX) and TikZ calligraphy library How do the comment replies (aka &quot;pinging users&quot;) work?  Who can I send an @reply to? How do I respond to a specific user when entering my comment? Will they be notified? What do people mean when they talk about &quot;pinging&quot; another user?  Related: Let $X \subset L^1(\mathbb{R})$ a closed linear subspace satisfying \begin{align} X\subset \bigcup_{p&gt;1} L^p(\mathbb{R})\end{align}    Show that $X\subset L^{p_0}(\mathbb{R})$ for some $p_0&gt;1.$   I guess the problem is that in infinite measure spaces the inclusion $L^p\subset L^q$ only holds for $p=q$. Is it maybe possbile to apply Baire's Theorem in some way? Why use hex? Hey! I was looking at this code at   I noticed that in some situations they used hex numbers, like in line 134:  for (j = 1; val &amp;&amp; j &lt;= 0x80; j &lt;&lt;= 1, q++)   Now why would they use the 0x80? I am not that good with hex but I found an online hex to decimal and it gave me 128 for 0x80.  Also before line 134, on line 114 they have this:  small_n = (n &amp; 0xffff0000) == 0;   The hex to decimal gave me 4294901760 for that hex number. So here in this line they are making a bit AND and comparing the result to 0??  Why not just use the number? Can anyone please explain and please do give examples of other situations.  Also I have seen large lines of code where it's just hex numbers and never really understood why :( Hexadecapole potential using point particles? We can get monopole $1/r$, dipole $1/r^2$, quadrupole $1/r^3$ and octupole $1/r^4$ potential falloff by placing opposite point charges at the corners of a point, line, square and cube, respectively. My book cryptically says "and so on", how does one get a $1/r^5$ and higher potential falloff with a finite number of point-charges in 3 dimensions? How are ETF prices calculated after the market is closed For example:  Because the NASDAQ: DAX is tracking the index INDEXDB: DAX should its trading value be completely flat when the market the markets are open in the US, but closed in Germany? I'm not seeing that artifact in any of the charts I can find. When will "Present Perfect vs. Past Tense" cases be affected by culture? Regarding actions taken in the past, besides the differences those two tenses have semantically, my teacher shared that it could be a British vs American English case.   When talking about past action, British prefers present perfect because they take into account that the effect from their past action still happens until now. As for American, they prefer to state the action only. It happened in the past, so past tense it is.     I have had dinner. [British]   vs.      I had dinner. [American]   I hope to hear it from the native speakers, both British and American. What do you think about this? Is it true?  If it is, I don't think it can apply to all cases of past actions. There have to be cases when both style agree to use the same tenses. Could you please help me define the situation when this kind of difference applies and when doesn't? Are locks unnecessary in multi-threaded Python code because of the GIL? If you are relying on an implementation of Python that has a Global Interpreter Lock (i.e. CPython) and writing multithreaded code, do you really need locks at all?  If the GIL doesn't allow multiple instructions to be executed in parallel, wouldn't shared data be unnecessary to protect?  sorry if this is a dumb question, but it is something I have always wondered about Python on multi-processor/core machines.    same thing would apply to any other language implementation that has a GIL. Like the ModelBuilder of ArcGIS Desktop to run simultaneous geoprocessing tools, is there any model builder available in QGIS? What is the origin of "a cut above/below the rest"? What does negative R-squared mean? Let's say I have some data, and then I fit the data with a model (a non-linear regression). Then I calculate the R-squared ($R^2$).  When R-squared is negative, what does that mean? Does that mean my model is bad? I know the range of $R^2$ can be [-1,1]. When $R^2$ is 0, what does that mean as well? Rationale behind pronunciation of "subtle" How can I randomise the output of a redstone circuit? Why is it that     All right angles are equal to each other    -a postulate in Euclid's Elements (). Shouldn't it be a congruence rather than an equivalence? Isn't this just a special case of the definition of congruent angles? For example: $$7x \equiv 1 \pmod{31} $$ In this example, the modular inverse of $7$ with respect to $31$ is $9$. How can we find out that $9$? What are the steps that I need to do? Update If I have a general modulo equation: $$5x + 1 \equiv 2 \pmod{6}$$ What is the fastest way to solve it? My initial thought was: $$5x + 1 \equiv 2 \pmod{6}$$ $$\Leftrightarrow 5x + 1 - 1\equiv 2 - 1 \pmod{6}$$ $$\Leftrightarrow 5x \equiv 1 \pmod{6}$$ Then solve for the inverse of $5$ modulo 6. Is it a right approach? Thanks.