4

I am trying to get the data from the custom tag 'data-tabval' but I am unable to get the value of it

<a href="#angular_code" role="tab" id="angular_code-tab" data-toggle="tab" aria-controls="angular_code">
   <span id="val" data-tabval="{{ tp }}" class="text">{{ tp }}</span>
</a>

angular_code: means there is some angular code I want the value of 'data-tabval' into jquery

I have tried many methods from morning to evening but am not getting specific results. Please if anyone can help me out

3 Answers3

2

You can use simply the jquery .attr to get the required output.

console.log($("#val").attr('data-tabval'))
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#angular_code" role="tab" id="angular_code-tab" data-toggle="tab" aria-controls="angular_code">
   <span id="val" data-tabval="test123" class="text">test here</span>
</a>
Mayank Patel
  • 1,563
  • 1
  • 14
  • 19
1

you can Gate custom Attribute value this code example:

$("a").click(function(event) {
      alert($(this).attr("aria-controls"));
      alert($(this).attr(" data-toggle"));
});

And others attribute or custom attribute

Md. Abu Sayed
  • 2,396
  • 2
  • 18
  • 26
1

Here is the code snippet for your requirement:

var value = $("#val").attr("data-tabval");