How can I horizontally center an element?

You can apply this CSS to the inner <div>: #inner { width: 50%; margin: 0 auto; } Of course, you don’t have to set the width to 50%. Any width less than the containing <div> will work. The margin: 0 auto is what does the actual centering. If you are targeting Internet Explorer 8 (and later), it … Read more

Reference — What does this symbol mean in PHP?

Incrementing / Decrementing Operators ++ increment operator — decrement operator Example Name Effect ——————————————————————— ++$a Pre-increment Increments $a by one, then returns $a. $a++ Post-increment Returns $a, then increments $a by one. –$a Pre-decrement Decrements $a by one, then returns $a. $a– Post-decrement Returns $a, then decrements $a by one. These can go before or … Read more

How do I create a GUID / UUID?

[Edited 2021-10-16 to reflect latest best-practices for producing RFC4122-compliant UUIDs] Most readers here will want to use the uuid module. It is well-tested and supported. The crypto.randomUUID() function is an emerging standard that is supported in Node.js and an increasing number of browsers. If neither of those work for you, there is this method (based … Read more

Regular expression to match a line that doesn’t contain a word

The notion that regex doesn’t support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds: ^((?!hede).)*$ Non-capturing variant: ^(?:(?!:hede).)*$ The regex above will match any string, or line without a line break, not containing the (sub)string ‘hede’. As mentioned, this is not something regex is “good” at (or should … Read more

How do I check whether a checkbox is checked in jQuery?

How do I successfully query the checked property? The checked property of a checkbox DOM element will give you the checked state of the element. Given your existing code, you could therefore do this: if(document.getElementById(‘isAgeSelected’).checked) { $(“#txtAge”).show(); } else { $(“#txtAge”).hide(); } However, there’s a much prettier way to do this, using toggle: $(‘#isAgeSelected’).click(function() { … Read more