3 examples of 'javascript change image' in JavaScript

Every line of 'javascript change image' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
415function updateImage(value, w, h)
416 {
417 var select = null;
418 var cells = graph.getSelectionCells();
419
420 graph.getModel().beginUpdate();
421 try
422 {
423 // Inserts new cell if no cell is selected
424 if (cells.length == 0)
425 {
426 var gs = graph.getGridSize();
427 cells = [graph.insertVertex(graph.getDefaultParent(), null, '', gs, gs, w, h)];
428 select = cells;
429 }
430
431 graph.setCellStyles(mxConstants.STYLE_IMAGE, value, cells);
432 graph.setCellStyles(mxConstants.STYLE_SHAPE, 'image', cells);
433
434 if (graph.getSelectionCount() == 1)
435 {
436 if (w != null && h != null)
437 {
438 var cell = cells[0];
439 var geo = graph.getModel().getGeometry(cell);
440
441 if (geo != null)
442 {
443 geo = geo.clone();
444 geo.width = w;
445 geo.height = h;
446 graph.getModel().setGeometry(cell, geo);
447 }
448 }
449 }
450 }
451 finally
452 {
453 graph.getModel().endUpdate();
454 }
455
456 if (select != null)
457 {
458 graph.setSelectionCells(select);
459 graph.scrollCellToVisible(select[0]);
460 }
461 };
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

176function changeImg(index) {
177 var list = obj1.getElementsByTagName('img');
178 var list1 = obj1.getElementsByTagName('font');
179 for (i = 0; i < list.length; i++) {
180 list[i].style.display = 'none';
181 list1[i].style.backgroundColor = 'white';
182 }
183 list[index].style.display = 'block';
184 list1[index].style.backgroundColor = 'blue';
185}
150function changeImage(imageIndex) {
151 if (imageIndex >= 0) {
152 activeImage = imageIndex;
153 activeURL = images[activeImage][0];
154
155 stop();
156 center.className = "lbLoading";
157
158 preload = new Image();
159 preload.onload = animateBox;
160 preload.src = activeURL;
161 }
162
163 return false;
164}

Related snippets