JQuery inner HTML element

I am getting an inner HTML element like this:

$(this).context.innerHTML

      

Then I get the parent inner HTML:

$(this).parent().context.innerHTML

      

But this code returns the same values. Any ideas what is wrong?

+2


a source to share


2 answers


To get the content of an element, then its content by the parent jQuery markup would be

$(this).html();

      

and



$(this).parent().html();

      

http://api.jquery.com/html/

+7


a source


The context for both queries is the same, which in this case is the element that represents this

. The parent()

context doesn't change when you call . This is the item that this

represents.

You can specify the context of the request, for example:

$("...", contextElement)

      



For more information visit:

+1


a source







All Articles