I have a Kendo UI grid that is rendered with javaScript. I want the string columns to have a single option (“Contains”) and without the second filter. So far so good, I wrote As part of the definition of the grid. And the result looks good-ish (I only have one option, so the drop down is redundant…
Tag: javascript
Remove first child in javascript
I’m trying to remove the first li in an ol using the DOM removeChild(). But for some reason it doesn’t work. This is my javascript: And this is my HTML: I tried alerting the childNodes[0], and it returns [Object Text], which seems a bit weird, when I was expecting just the object. Hope I’ve …
How do I add text to specific div element using jQuery?
I am having a problem with jquery. My HTML is Now I am trying to add text in span using Jquery. After that it becomes, But, I am tryting to achieve is, How can I do that in jquery? Answer Several possible alternatives Others have provided their answers already but let me give you some more alternatives. The s…
Inject Javascript code into a web page
I’d like to download web page as html file. Before I save the web page source code in html file, I’d like to edit some of the page content first. I assume I can edit the content using Javascript. Unfortunately I have little experience with Javascript. I guess I have to inject my script into the we…
add event listener on elements created dynamically
Is possible to add event listener (Javascript) to all dynamically generated elements? I’m not the owner of the page, so I cannot add a listener in a static way. For all the elements created when the page loaded I use: I need a method to call this code when new elements appear on the page, but I cannot u…
Bootstrap close responsive menu “on click”
On “PRODUCTS” click I slide up a white div (as seen in attached). When in responsive (mobile and tablet), I would like to automaticly close the responsive navbar and only show the white bar. I tried: also tried: And it does work. However in desktop size, it is also called and does something funky …
Convert SVG Path to Relative Commands
Given an SVG Path element, how can I convert all path commands into relative coordinates? For example, convert this path (which includes every command, absolute and relative, interleaved): into this equivalent path: This question was motivated by this question. Answer Snap.SVG has Snap.path.toRelative(). Fidd…
How do I JSON encode only part of a Javascript object?
I’m writing a 2D gravity simulation game and I’m trying to add save/load functionality. In the game I store all of the current planets in an array. Each planet is represented by a Body object which contains the coordinates, mass, and motion vector of the planet. It also stores an array of the last…
Get name and line of calling function in node.js
How can one get the name and line of a function that called the current one? I would like to have a rudimentary debugging function like this (with npmlog defining log.debug): When called from another function it would be something like this: For clarity, what I want is essentially analogous to this in Python:…
Moment.js – how do I get the number of years since a date, not rounded up?
I’m trying to calculate a person’s age using Moment.js, but I’m finding that the otherwise useful fromNow method rounds up the years. For instance, if today is 12/27/2012 and the person’s birth date is 02/26/1978, moment(“02/26/1978”, “MM/DD/YYYY”).fromNow() ret…