-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?

Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94

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)
Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94
Raman Choudhary
  • 4,143
  • 2
  • 13
  • 25