cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              jQuery(document).ready(function($) { 
"use strict";
// This sets up no conflict mode and makse the $ symbol aviable inside the .ready();

// This is the first option an probaly the best if you can add a class to each of your elements.
// also I used the .change instead of .on("change" handler) this is the shortcut.

// For the elementName var I used the plain javascript .slice method to get everthing, but the last 
// letter, concatenated the "Name" string then concatenated the last letter or number in this case 

function onPhotoChange() {
  $(".photoClass").change(function () {
    var elementID = $(this).attr('id'),
    elementName = elementID.slice(0,-1) + "Name" + elementID.slice(-1);
    $(elementName).val($(this).val().replace(/C:\\fakepath\\/i, ''));

// If you can't add a class to each image you could create an array, then convert the array to a string and 
// pass the comma separted string into the $ selector. Everything else stayed the same.

function createArray() {
  var myArray =[ "#photo0", "#photo1", ..... , "#photo12"  ],
  selectorList = myArray.toString();
  $(selectorList).change(function () {
    var elementName = $(this).slice(0,-1) + "Name" + $(this).slice(-1);
    $(elementName).val($(this).val().replace(/C:\\fakepath\\/i, ''));


 // Here is an example of a listner function same concept as above 

 function photoHoverListener() {
    $(".photoClass").hover(function() {
      var elementID = $(this).attr('id'),
      elementName = elementID.slice(0,-1) + "Browse" + elementID.slice(-1);
}); // End of .ready(); Can no longer use $ in no conflict mode

Loading ..................