-1

I have the following code:

<ul class="offers-list row">
  <li class="column large-3 offers-image" name="orden-1">
    <a title="Title" href="my-ofer-link">
        <img src="my-image-src" border="0">
    </a>
  </li>
</ul>

Using jQyery, I'm trying to select the li element like this:

$('.offers-list.row li').last()  // I use last because I have more than one

And I want to get the full li element, so I tried this:

$('.offers-list.row li').last().html()

But then it only shows the content of the li element. Like this:

"<a title="Title" href="my-ofer-link">
    <img src="my-image-src" border="0">
</a>"

How can I also get the li element?

Sonhja
  • 7,947
  • 16
  • 69
  • 124

1 Answers1

2

You can use .outerHTML with dom object of returned element

$('.offers-list.row li').last()[0].outerHTML
Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120