views:

71

answers:

2

I have

$('#hidden-data').find('#' + $(this).attr('id')).html(currdata);
var hiddata = $('#hidden-data').find('#' + $(this).attr('id')).html();

I want to translate this to javascript but my brain is melted. Please help ;p

+3  A: 

The simplest version, given that IDs should be unique:

var hiddata = this.innerHTML = currdata;

The shortened jQuery version accounting for ID uniqueness makes this a bit more apparent:

$(this).html(currdata);
var hiddata = $(this).html();

Since you're taking the id attribute from this and no other element should have that ID, just use this, no need to find anything else in the DOM...you should already have the element.

Nick Craver
+1  A: 
var o = document.getElementById(thisid);
o.innerHTML = currdata;
var hiddata = o.innerHTML;
methodin