Skip to content

Tag: javascript

How to show a popup modal in codeIgniter?

I have written a javascript click function to a class to display a popup when the relevant class be clicked. When i just put an alert it gives me the correct output. but the popup modal is doesn’t show up Model I am using following model function And i am calling that method in the following controller …

Convert javascript object camelCase keys to underscore_case

I want to be able to pass any javascript object containing camelCase keys through a method and return an object with underscore_case keys, mapped to the same values. So, I have this: And I want a method to output this: What’s the fastest way to write a method that takes any object with any number of key…

Check if element is partially in viewport

I’m trying to determine if an element is partially or fully in the viewport. I’ve found this which will determine if an element is fully in view but kept getting confused when trying to determine partial visibility. I don’t want to use jQuery. Basically, the idea is that there will be an ele…

Calculate percentage Javascript

I have a question about javascript logic what I use to get percent of two inputs from my text fields. Here is my code: For some reason if my inputs are 600 and 200, my result suppose to be 33.333 but I’m getting 3.333. If I hard code my values this works fine. If anyone can help I appreciate that.