-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
  • 8,230
  • 20
  • 73
  • 131

1 Answers1

2

You can use .outerHTML with dom object of returned element

$('.offers-list.row li').last()[0].outerHTML
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125