What is a Vanilla JS or jQuery solution that will select all of the contents of a textbox when the textbox receives focus? Answer
How to do JSLint in Vim
I spend my days in vim, currently writing a lot of JavaScript. I’ve been trying to find a way to integrate JSLint or something similar into vim to improve my coding. Has anyone managed to do something like this? I tried this: Javascript Syntax Checking From Vim, unfortunately the output is very crude. Answer You can follow the intructions from
Print only?
How do I print the indicated div (without manually disabling all other content on the page)? I want to avoid a new preview dialog, so creating a new window with this content is not useful. The page contains a couple of tables, one of them contains the div I want to print – the table is styled with visual styles
Pass parameters in setInterval function
Please advise how to pass parameters into a function called using setInterval. My example setInterval(funca(10,3), 500); is incorrect. Answer You need to create an anonymous function so the actual function isn’t executed right away.
Creating a textarea with auto-resize
There was another thread about this, which I’ve tried. But there is one problem: the textarea doesn’t shrink if you delete the content. I can’t find any way to shrink it to the correct size – the clientHeight value comes back as the full size of the textarea, not its contents. The code from that page is below: Answer This
Create a Date with a set timezone without using a string representation
I have a web page with three dropdowns for day, month and year. If I use the JavaScript Date constructor that takes numbers, then I get a Date object for my current timezone: Give the correct date, but it thinks that date is GMT+01:00 due to daylight savings time. The problem here is that I then pass this Date to
Where should I put tags in HTML markup?
When embedding JavaScript in an HTML document, where is the proper place to put the <script> tags and included JavaScript? I seem to recall that you are not supposed to place these in the <head> section, but placing at the beginning of the <body> section is bad, too, since the JavaScript will have to be parsed before the page is
Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser
I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explorer 8, Google Chrome and Mozilla FireFox 3. Any suggestions to a full cross-browser solution? Something like a well-tested jQuery library or maybe just vanilla
RegEx for Javascript to allow only alphanumeric
I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow either and not require both. Answer Update (supporting universal characters) if you need to this regexp supports universal character you can find
Use Javascript to change which submit is activated on enter key press
I have a form on an HTML page with multiple submit buttons that perform different actions. However, when the user is typing a value into a text input and hit enters, the browsers generally act as though the next submit button sequentially was activated. I want a particular action to occur, so one solution I found was to put in