Animate an image size on click with jQuery

Im trying to animate a large image so it changes dimensions, starts at (200×116)px and becomes (400×232)px on click and then would revert back to (200×116)px if clicked again, Here’s a link to the code: HTML: <img id=”imgtab” src=””> CSS: #imgtab { position:relative; } JavaScript: $(document).ready(function () { $(“#imgtab”).toggle(function () { //fired the first […]

changing active class for list element

I’m trying to change the ‘active’ class for the clicked list item but I’m missing something. Here is what my HTML and jquery look like: HTML <ul class=”additional-menu”> <li class=”active”><a href=”link1″> Link1</a></li> <li><a href=”javascript:void(0)” id=”link2″>Link2</a></li> <li><a href=”javascript:void(0)” id=”link3″>Link3</a></li> </ul> jQuery $(“#link2”).click(function(){ if ($(this).find(‘#additional-menu li’).hasClass(‘active’)) { //console.log(“Active class seen”); $(this).find(‘#additional-menu li’).removeClass(‘active’); $(this).addClass(‘active’); } }); Any idea […]

Simple form submit with files

I am trying to write a simple upload form with input file type using React JS. When i submit the file, it is not submitting multi form data. It is submitting plain input file name. Do we need to make any other changes if we want to write upload functionality in React. Basic javascript code […]

Python Pandas equivalent in JavaScript

With this CSV example: Source,col1,col2,col3 foo,1,2,3 bar,3,4,5 The standard method I use Pandas is this: Parse CSV Select columns into a data frame (col1 and col3) Process the column (e.g. avarage the values of col1 and col3) Is there a JavaScript library that does that like Pandas?

How to tell if an element is a child of another element in JavaScript (no jQuery)?

If I have 2 HTML elements, how can I easily tell if 1 is a child of the other? var parent = document.getElementById(‘shapes’); var child = document.getElementById(‘star’); Is there any kind of function on an element like child.getParentElement() that I could compare with like child.getParentElement() == parent? I understand parent.children gives me back an array […]

How to hover mutiple “div” in the same time?

I have <div id=”d1″ class=”hov”></div> and <div id=”d2″ class=”hov”></div> and the CSS is .hov:hover{ background-color:#cde0c4; cursor:pointer; } When I hover on d1 I want d2 is hover same. How to hover multiple DIVs at the same time?

Javascript function this.title, this.value

I have a form which onchange passes values to a javascript function. I have managed to get this.value and student.value passed but this.title does not return anything. How would i go about getting the title of the option? Thanks <form> <select id=”student” style=”width:100%”> <option value=””>–</option> <option value=””>A</option> </select> <select id=”course” onchange=”showarchive(this.value, this.title, student.value)” style=”width:100%”/> <option […]

Parent of an id using Jquery

<div class=”cdlButton” style=”width:40px; float: left;”> // want this div element <div style=””> <a id=”changestatus” class=”” onclick=”changeWorkflowStatus()” href=”#”> <img id=”” width=”32px” height=”32px” title=”disable” alt=”disable” src=”images/disable.png”> </a> </div> </div> I want div with help of jquery Right now i am doing this way $(“#changestatus “).parent().parent().addClass(‘disablecdlButton’); Is there any other way to get top div element

Javascript closure setTimeout interval issue

Why is the following logged every 1 second? I’m multiplying 1000 milliseconds to the increment. Shouldn’t my logs show up after 1 second, then 2 seconds, then 3 seconds? for (var i = 0; i < 5; i++) { (function(r) { setTimeout( function() { console.log(r) } , r * 1000 ); })(i) } JSFIDDLE

How do I union/merge two Collections by their 'id' using UnderscoreJS

I have two collections (Menu and Orders) Menu collection contains array of Item objects [{‘id’: ‘1’, ‘name’: ‘apple’}, {‘id’: ‘2’, ‘name’: ‘orange’}] And Orders collection also contains array of Item objects [{‘id’: ‘1’, ‘quantity’: ‘0’}] And I want them merged together their attributes by ID into another collection (this is needed for templating purposes only): […]