-5

When I do console.log($(this)); I got the following information:-

Image Here

I want to join the $(this), go into context, and then into attributes. How?

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98

1 Answers1

0

Suppose you want to get the attribute from this element-

<div class="test_class" data-somevalue="this is value"> </div>

You can use-

$(".test_class").attr("data-somevalue")
//or
$(".test_class").data("somevalue")

In your case, you can also use

const finalVal = Object.assign({}, $(this), $(this).context, $(this). attributes)
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Raman Choudhary
  • 4,283
  • 2
  • 14
  • 25