call function with className.onclick JS

var el = document.getElementsByClassName(“elements”); // this element contains more than 1 DOMs. el.onclick = function() { console.log(“target name should be here”)}; So I don’t want to have inline JS, I want to fire function when it click to a specific DOM that has same class to any other elements. Could anyone help please?

Make <select> options “click” automatically

Let’s say I’ve got a drop down like this: <div class=”selector”> <select name=”perPage”> <option value=”5″>5</option> <option value=”10″>10</option> <option value=”15″>15</option> <option value=”25″>25</option> </select> </div> I’m know PHP and Javascript (jQuery) so a solution in either would be just fine. But I’ve got a submit button underneath it, and instead of that, I was wondering if there’s […]

Using JavaScript to add a table rows that have input fields

So I’m trying to add extra input fields within a table row using JavaScript, and I can’t seem to figure out. My approach right now is to just insert extra html code and add a new table row every time someone clicks the “add more” button. Here’s my code right now HTML <div class=”set-form”> <table […]

Passing a value to AngularJS click event

Suppose I have a table like this: <tbody> <tr data-ng-repeat=”object in objects”> <td><input type=”checkbox” value=”{{object.id}}” data-ng-checked=”object.checked” data-ng-mode=”object.checked”/></td> <td>{{object.name}}</td> <td><a href=”#” class=”btn btn-default” data-ng-click=”objectEdit()”>Edit</a> <a href=”#” class=”btn btn-default”>View</a></td> </tr> </tbody> What is the right way to have objectEdit notified which entry in objects is being referenced here? Sorry, AngularJS newb.

Implement date Format similar to Java/C# (like “dddd/mm/yy”)

Overall I want to implement formatting function for JavaScript date values that accept strings similar to Java/C# formatting: “dddd/mm/yy” and like. My current problem is scoped to – I have a string with ‘d’s. The string can be like ‘d/dd/ddd/dddd’ ‘dd/d/ddd’ ‘dddd ddd /dd’ the gaps between d’s can be single/more white-spaces or :(colon) or […]

creating an instance of another object in javascript

I want to know whether this sentence is correct? You can do: var a = new A(); if and only if A is instanceof Function. Simply you can create an instance of function and you know a function is an object. Why can’t we create an instance of other user-defined objects? Like this: var b={}; […]

Jquery Change background color of DIV to #333 only when all checkbox is not checked

I have 5 div with class .thumb-folder and inside each contains a checkbox. I also have another div with a class .alarm. When 1 or many checkboxes is checked the div with .alarm class changes background to red. How to change the div with the .alarm class to background #333 only when no checkboxes are […]

How to “auto close” Alert boxes

We have a control that was made by a company that no longer exists. For some odd reason on page load it has now started rendering something like this to the page: <script type=”text/javascript”> alert(‘Your license has expired!’) </script> Since the company no longer exists we can’t get support and the control is also very […]

jQuery Perfect Scroll – Set Scrollbar to the Bottom of the Container

I have just installed perfect scroll, the jQuery plugin, and it works great but I can’t find a parameter to start the content at the bottom of my div. I want to have to scroll up on page load, not to have to scroll down. Normally with jQuery I would just do: $(nav_message_list).prop({ scrollTop: $(nav_message_list).prop(“scrollHeight”)}); […]

Compare template helper values in Spacebars {{#if}} block

I need to compare two template helper values that are located in nested templates. I was wondering if there is an easy way to compare two template helpers (one from the parent template) in an {{#if}} statement like so: {{#each bids}} {{#if bid.price===../job.price}} <span>some text</span> {{else}} <span>some other text</span> {{/if}} {{/each}} If you can’t do […]