I have a tag like this:
<a href="#" id="ssd" data-toggle="popover" data-info1="demo text: 1" data-info2="demo text: 2" data-info3="demo text3">Link</a>
When I click this link, I have a function like this
$('#ssd').click(function (event) {
var customData;
});
Please note that the data-info * like attributes can be any number, which means that you can see one of them called data-info1, or from them, named data-info1, data-info2, data-info3.
How would I do this, I was looking for a jQuery selector, something like Attribute Starts With Selector [name ^ = "value"] will not work, because here the variation is by name ...
If I console.log($('#ssd').data());, I get an object with additional attributes that I donโt need,toggle: "popover", bs.popover: Popover
Any suggestions?
This is what I did:
dataFullList = $(this).data();
$.each(dataFullList, function (index, value) {
if (index !== "toggle" && index !== "bs.popover") {
item.name = value.split(":")[0];
item.number = value.split(":")[1];
dataIWant.push(item);
}
});
So, I will get an array dataIWantwithout any things that I do not need.