I'm trying to target all divs of a certain class and apply innerHTML. This is what I have, but I'm getting no errors and no result.
$( ".programdesc" ).innerHTML( '<p>I am alive</p>' );
Any pointers?
I'm trying to target all divs of a certain class and apply innerHTML. This is what I have, but I'm getting no errors and no result.
$( ".programdesc" ).innerHTML( '<p>I am alive</p>' );
Any pointers?
Use the html function :
$( ".programdesc" ).html( '<p>I am alive</p>' );
You should use each
$( "div.programdesc" ).each(function() {
(this).innerHTML( '<p>I am alive</p>' );
});
innerHTML
is a property of a DOM Element, not a function. The property exists in pure Javascript, not in jQuery statements.
$(".programdesc").html( 'this is the jQuery way' );
document.getElementsByClassName('programdesc').index(0).innerHTML = "This is the Javascript way";