How can I access seq value in a href, when I click thye link?
/* Add a listner to Group buttons */
$('a.preActNav').click(function() {
alert(this.seq)
});
<li><a href="#preclose4" data-theme="a" data-icon="arrow-d" data-transition="none" seq='1' class="preActNav" ID="preActNavA">A</a></li>
<li><a href="#preclose4" data-theme="a" data-icon="arrow-d" data-transition="none" seq='2' class="preActNav" ID="preActNavB">B</a></li>
jQuery click() MethodThe click event occurs when an element is clicked. The click() method triggers the click event, or attaches a function to run when a click event occurs.
To trigger the onclick function in jQuery, click() method is used. For example, on clicking a paragraph on a document, a click event will be triggered by the $(“p”). click() method. The user can attach a function to a click method whenever an event of a click occurs to run the function.
click() shorthand is deprecated at jQuery 3 on() and . trigger() methods can set an event handler or generate an event for any event type, and should be used instead of the shortcut methods.
The click() method simulates a mouse-click on an element. This method can be used to execute a click on an element as if the user manually clicked on it.
Like this:
alert($(this).attr('seq'));
Although it may be better to put seq
as another data element:
<li><a href="#preclose4" data-theme="a" data-icon="arrow-d" data-transition="none" data-seq='1' class="preActNav" ID="preActNavA">A</a></li>
So then you can do:
alert($(this).data('seq'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With