//uploading images within the div
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails.
for (var i = 0, f; f = files[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
var txtval=$('#textid').val();
addplus1 = 1;
txtval=parseInt(txtval)+parseInt(addplus1);
//txtval+=addplus1;
alert(txtval);
$('#textid').val(txtval);
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
var div =document.createElement('div');;
div.idName="editableid";
div.innerHTML = ['<img class="imgclass" src="', e.target.result,
'" width="140px" height="140px" /><br><span class="insidespan" style="color:red" contenteditable="true">Click and type!</span> '].join('');
document.getElementById('bordergreen').insertBefore(div, null);
var spans = document.getElementsByClassName('insidespan');
for (var i = 0, len = spans.length; i < len; i++) {
spans[i].onclick = placehodertype;
}
var images = document.getElementsByClassName('imgclass');
for (var j = 0, leng = images.length; j < leng; j++) {
images[j].onclick = RemoveImage;
}
};
})(f);
// Read in the image file as a data URL.
reader.readAsDataURL(f);
}
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
function placehodertype() {
// alert((this.textContent || this.innerText));
var textval=(this.textContent || this.innerText);
if(textval=="Click and type!")
{
$(this).text("");
$(this).focus();
}
$(this).blur(function(){
var textval2 =(this.textContent...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.