Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

***
$('#checkbox').is(':checked');
***
The above code returns true if the checkbox is checked or false if not.
4 years ago
Unicode arrows heads:

? - U+25B2 BLACK UP-POINTING TRIANGLE
? - U+25BC BLACK DOWN-POINTING TRIANGLE
? - U+25B4 SMALL BLACK UP-POINTING TRIANGLE
? - U+25BE SMALL BLACK DOWN-POINTING TRIANGLE
For ? and ? use ▲ and ▼ respectively if you cannot include Unicode characters directly (use UTF-8!).
4 years ago
Simply supplying the HTML of elements you want to add to a jQuery constructor $() will return a jQuery object from newly built HTML, suitable for being appended into the DOM using jQuery's append() method.

For example:
***
var t = $("
");
$.append(t);
***
You could then populate this table programmatically, if you wished.

This gives you the ability to specify any arbitrary HTML you like, including class names or other attributes, which you might find more concise than using createElement and then setting attributes like cellSpacing and className via JS.
4 years ago
This is quick, easy, to the point and doesn't require any third-party script:
***
type="application/pdf">
***
4 years ago
For dropdown options you probably want something like this:
***
var conceptName = $('#aioConceptName').find(":selected").text();
***
The reason val() doesn't do the trick is because clicking an option doesn't change the value of the dropdown--it just adds the :selected property to the selected option which is a child of the dropdown.
4 years ago
You should add the target="_blank" and rel="noopener noreferrer" in the anchor tag.

For example:
***
Link
***
Adding rel="noopener noreferrer" is not mandatory, but it's a recommended security measure.
4 years ago
using Javascript:
a) Adding inline style
***
document.head.insertAdjacentHTML('beforeend', '');
***
b) or a bit harder method - adding "mouseover"
***
document.getElementById("mydiv").onmouseover= function(e){this.className += ' my-special-class'; };
document.getElementById("mydiv").onmouseleave= function(e){this.className = this.className.replace('my-special-class',''); };
***
4 years ago
Given that canvas is a canvas element,
***
const context = canvas.getContext('2d');

context.clearRect(0, 0, canvas.width, canvas.height);
***
4 years ago
You should not use regular expressions to validate an input string to check if it's an email. It's too complicated and would not cover all the cases.

Now since you can only cover 90% of the cases, write something like:
***
function isPossiblyValidEmail(txt) {
return txt.length > 5 && txt.indexOf('@')>0;
}
***
You can refine it. For instance, 'aaa@' is valid. But overall you get the gist. And don't get carried away... A simple 90% solution is better than 100% solution that does not work.

The world needs simpler code...
4 years ago
the solution to does not start with “hede”:
***
^(?!hede).*$
***
is generally much more efficient than the solution to does not contain “hede”:
***
^((?!hede).)*$
***
The former checks for “hede” only at the input string’s first position, rather than at every position.
4 years ago
grep -v is your friend:
***
grep --help | grep invert
***
-v, --invert-match select non-matching lines

Also check out the related -L (the complement of -l).

-L, --files-without-match only print FILE names containing no match
4 years ago
I once had to use CDATA when my xml element needed to store HTML code. Something like
***

my para


]]>

***
So CDATA means it will ignore any character which could otherwise be interpreted as XML tag like < and > etc.
4 years ago