jQuery - How to select value by attribute name starts with
问题 I want to select attribute value by giving attribute name (only starts with) For instance if we have html tag <div class = \"slide\" data-confirmID = \"46\" confirmID = \"54\"/> I want to select the value from the attribute starts with data- Thanks in advance for the help. 回答1: If you want all data-* attributes, you can iterate through jq data object: $('.slide').each(function(){ for(data in $(this).data()) console.log(data); // returns confirmID so element as an attribute `data-confirmID` })