大约有 17,000 项符合查询结果(耗时:0.0389秒) [XML]
Get the device width in javascript
...e a way to get the users device width, as opposed to viewport width, using javascript?
12 Answers
...
How do you get a string to a character array in JavaScript?
How do you convert a string to a character array in JavaScript?
13 Answers
13
...
Check if object value exists within a Javascript array of objects and if not add a new object to arr
...and examples using .some found here - developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
– James Marino
Jul 9 '18 at 23:43
...
Create a hexadecimal colour based on a string with JavaScript
...rting over the Java from Compute hex color code for an arbitrary string to Javascript:
function hashCode(str) { // java String#hashCode
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash;
}
function i...
Javascript equivalent of Python's zip function
Is there a javascript equivalent of Python's zip function? That is, given multiple arrays of equal lengths create an array of pairs.
...
Set cookie and get cookie with JavaScript [duplicate]
...
Check JavaScript Cookies on W3Schools.com for setting and getting cookie values via JS.
Just use the setCookie and getCookie methods mentioned there.
So, the code will look something like:
<script>
function setCookie(c_nam...
How to replace DOM element in place using Javascript?
...rflow.com">StackOverflow</a>
</div>
<script type="text/JavaScript">
var myAnchor = document.getElementById("myAnchor");
var mySpan = document.createElement("span");
mySpan.innerHTML = "replaced anchor!";
myAnchor.parentNode.replaceChild(mySpan, myAnchor);
</script&g...
How do you get the length of a string?
...
but this still just uses javascript doesn't it? same as @Artem Barger's answer
– Malcolm Salvador
Jul 31 '17 at 1:37
add a co...
Stop an input field in a form from being submitted
I'm writing some javascript (a greasemonkey/userscript) that will insert some input fields into a form on a website.
12 Ans...
Find a value in an array of objects in Javascript [duplicate]
...ml#_searching-for-array-elements
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find
To then replace said object (and use another cool ES6 method fill) you could do something like:
let obj = array.find(x => x.name === 'string 1');
let index = array.indexOf(o...
