...

View Full Version : Retrieveing & inserting contents



defencedog
01-20-2012, 04:05 AM
@ http://jsfiddle.net/defencedog/cu5VJ/

I am having problem in understanding the operation of js with regards to this line

$('.' + x[i].id).text(x[i].innerHTML);
or


$('.' + x[i].id).html(x[i].innerHTML);


I want to understand why I ain't able to produce desired results while using this instead


$('.' + x[i].id).innerHTML(x[i].innerHTML);

devnull69
01-20-2012, 07:14 AM
Because .innerHTML simply isn't a method of a jQuery object whereas .html() is ... .innerHTML is a property of a DOM element and not a method



// get a DOM element
var DOMel = document.getElementById('myid');
DOMel.innerHTML = "<b>whatever</b>";

// get a jQuery object and set its html
$('#myid').html("<b>whatever</b>");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum