Skip to content
Advertisement

Filter search for

I have a list of users as well: what I want is a text input each time you write a letter to display only users that start with that letter or that they might have the name. As I can do? It is with jquery but not as … Answer Here is a input that filters a <ul> based on

Getting selected options with querySelectorAll

I wonder if it’s possible in Javascript to get the currently selected options in a <select multiple> field using the Selctors API rather than a “stupid” iteration over all options. select.querySelectorAll(‘option[selected=”selected”]’) only returns the options that were marked as preselected in the original HTML, which is not what I’m looking for. Any ideas? Answer document.querySelectorAll(‘option:checked’) Works even on IE9 😉

Canvas clip image with two quadraticCurves

I just wanted to clip image in a curve .. but not happening this.. Only image is showing and but not with clip. Answer You have to move everything from the line context.save(); to context.clip(); inside the function object of your imgObj’s onload handler: See http://jsfiddle.net/CSkP6/1/ for an example.

Method to show native datepicker in Chrome

I use <input type=”date”> fields that gracefully fallback to jQuery when the browser does not have support for the field. Relatively recently, Chrome started offering a native date picker, which is great. But I have found that many users miss the little arrow that brings up the calendar and therefore miss the fact that there is an easy calendar for

Find by key deep in a nested array

Let’s say I have an object: I want to find the one object where the id is 1. Is there a function for something like this? I could use Underscore’s _.filter method, but I would have to start at the top and filter down. Answer Recursion is your friend. I updated the function to account for property arrays: updated jsFiddle:

Inject CSS stylesheet as string using Javascript

I’m developing a Chrome extension, and I’d like users to be able to add their own CSS styles to change the appearance of the extension’s pages (not web pages). I’ve looked into using document.stylesheets, but it seems like it wants the rules to be split up, and won’t let you inject a complete stylesheet. Is there a solution that would

Use of commas versus semicolons?

Given the following code: As can be seen, there is a mix of both. What would be the benefit of using one or the other? My understanding is that the semicolon is to end the statement. And comma should be used to string together multiple declarations. So is it safe to say that with this example then there should only

Enable Vim mode in gist Ace Editor

I’m trying to enable the Ace’s keyBoard handler for my beloved Vim on github gists. This seems like it would be an easy thing to do, but I am struggling to: Find the object that the gist ace editor is attached to (the ace default editor is not defined) Set it to use VIM, via github’s hosted Vim binding: https://gist.github.com/assets/ace/keybinding/vim-b9f3b98dd13151f9b4c7279d8259b69e.js

Advertisement