Jquery gets all element questions with specified attributes

there are many

<a href="-sharp" onclick="detail(201,3994123)" data-toggle="modal" data-target="-sharpdetailModal" class="btn  btn-xs btn-primary"></a>

<a href="-sharp" onclick="detail(201,3994453)" data-toggle="modal" data-target="-sharpdetailModal" class="btn  btn-xs btn-primary"></a>

<a href="-sharp" onclick="detail(201,3991253)" data-toggle="modal" data-target="-sharpdetailModal" class="btn  btn-xs btn-primary"></a>

such a tags, in which the common feature of these a tags is that the custom attribute data-toggle is equal to the value of-sharpdetailModal. I now want to get the attribute values of all such a tag onclick attributes. I use jq to get it, written as: $("a [data-target="-sharpdetailModal"]")-> attr ("onclick"), but this only gets the onclick attribute value of the first a tag. I would like to ask what is the reason at this time. Can"t you get the onclick attribute values of all such a tags?


Array.prototype.forEach.call($("a[data-target='-sharpdetailModal']"), (v) => {

    console.log($(v).attr('onclick'));
})

you need to traverse all a [data-target='-sharpdetailModal']


this kind of problem should first look at the document: jQuery .attr ()

Get the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.

I think it's possible
pseudo code:
loop all a tags
when $('a') [I]. Dataset.target ='- sharpdetailModa'
print console.log (this.attr ('onclick'))

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e952e7-153d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e952e7-153d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?