Most Popular

1500 questions
2467
votes
37 answers

Make a div fill the height of the remaining screen space

I am working on a web application where I want the content to fill the height of the entire screen. The page has a header, which contains a logo, and account information. This could be an arbitrary height. I want the content div to fill the rest of…
Vincent McNabb
  • 30,869
  • 6
  • 30
  • 52
2467
votes
19 answers

Disable/enable an input with jQuery?

$input.disabled = true; or $input.disabled = "disabled"; Which is the standard way? And, conversely, how do you enable a disabled input?
omg
  • 130,444
  • 137
  • 283
  • 343
2465
votes
44 answers

How do you display code snippets in MS Word preserving format and syntax highlighting?

Does anyone know a way to display code in Microsoft Word documents that preserves coloring and formatting? Preferably, the method would also be unobtrusive and easy to update. I have tried to include code as regular text which looks awful and gets…
Lawrence Barsanti
  • 29,923
  • 10
  • 45
  • 67
2462
votes
90 answers

Generate random string/characters in JavaScript

I want a 5 character string composed of characters picked randomly from the set [a-zA-Z0-9]. What's the best way to do this with JavaScript?
Tom Lehman
  • 80,263
  • 69
  • 195
  • 267
2452
votes
29 answers

How do I give text or an image a transparent background using CSS?

Is it possible, using CSS only, to make the background of an element semi-transparent but have the content (text & images) of the element opaque? I'd like to accomplish this without having the text and the background as two separate elements. When…
Stijn Sanders
  • 34,767
  • 9
  • 44
  • 65
2450
votes
35 answers

Get selected text from a drop-down list (select box) using jQuery

How can I get the selected text (not the selected value) from a drop-down list in jQuery?
haddar
  • 24,707
  • 3
  • 19
  • 12
2449
votes
27 answers

Docker: Copying files from Docker container to host

I'm thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don't have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artifacts that…
user2668128
  • 34,822
  • 8
  • 24
  • 31
2438
votes
18 answers

.prop() vs .attr()

So jQuery 1.6 has the new function prop(). $(selector).click(function(){ //instead of: this.getAttribute('style'); //do i use: $(this).prop('style'); //or: $(this).attr('style'); }) or in this case do they do the same…
Naftali
  • 142,114
  • 39
  • 237
  • 299
2438
votes
33 answers

Using async/await with a forEach loop

Are there any issues with using async/await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file. import fs from 'fs-promise' async function printFiles () { const files = await getFilePaths() //…
Saad
  • 41,639
  • 19
  • 63
  • 109
2431
votes
29 answers

Catch multiple exceptions at once?

It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try { WebId = new Guid(queryString["web"]); } catch…
Michael Stum
  • 172,735
  • 112
  • 392
  • 530
2428
votes
38 answers

How to create an HTML button that acts like a link

I would like to create an HTML button that acts like a link. So, when you click the button, it redirects to a page. I would like it to be as accessible as possible. I would also like it so there aren't any extra characters, or parameters in the…
Andrew
  • 212,236
  • 189
  • 499
  • 691
2426
votes
23 answers

What is reflection and why is it useful?

What is reflection, and why is it useful? I'm particularly interested in Java, but I assume the principles are the same in any language.
Lehane
  • 45,580
  • 14
  • 49
  • 53
2426
votes
16 answers

How do I show the changes which have been staged?

I staged a few changes to be committed; how can I see the diff of all files which are staged for the next commit? I'm aware of git status, but I'd like to see the actual diffs - not just the names of files which are staged. I saw that the…
Frerich Raabe
  • 86,449
  • 18
  • 111
  • 204
2422
votes
15 answers

How to list only the names of files that changed between two commits

I have a bunch of commits in the repository. I want to see a list of files changed between two commits - from SHA1 to SHA2. What command should I use?
Shawn
  • 30,399
  • 17
  • 44
  • 72
2421
votes
29 answers

Check if a variable is a string in JavaScript

How can I determine whether a variable is a string or something else in JavaScript?
Olical
  • 36,487
  • 11
  • 54
  • 76