indexing - index of clicked element to pop her event_id from array jquery -
For my example, I have 3 href tags so if I click on a href tag for the first time, Like to pop the event_id before the array variable. How can I solve it?
Here is my HTML code:
& lt; A href = "#" event-id = "class =" event_delete "& gt; Link & lt; / A & gt; & Lt; A href = "#" event-id = "class =" event_delete "& gt; Link & lt; / A & gt; & Lt; A href = "#" event-id = "class =" event_delete "& gt; Link & lt; / A & gt;
My jquery code here:
var event_id = new array (); // event_id first for a href tag event_id.push ("1X4JxCOwhDpD4Oj5ch"); // Event_ID for the second ARR tag event_ id.push ("LKB 77AAMVJZE 83LH"); // event_id third for a href tag event_id.push ("h0NTcpfUlinWbpwBbpB1"); JQuery ('. Event_delete'). Click (function () {var index = jQuery ('. Event_delete'). Index (this); // // .. //console.log(event_id.pop (???))})
Hope someone can help me.
It looks as if you should add the array ID with the link ID
jQuery ("a.event_delete"). Each (function (index, value) {jQuery (this) .attr ('id', event_id [index]); console.log (this);}); JQuery ('. Event_delete'). Click (function () {var index = jQuery ('. Event_delete'). Index (this); console.log (jQuery (this) .attr ('id'));};
But you can basically have an ID in HTML, as long as you are not getting them from another source.
Comments
Post a Comment