I am always looking for a shorter and faster way of making jQuery selections, and I wondered if there is a shorter way to select the value of the data attribute of a given element. Now I have this
const phoneCode = $('#loginCountryCodeInput').attr('data-phone-code');
to get the value of this data attribute
<input id="loginCountryCodeInput" data-phone-code="+1">
Is there a shorter selector, something like this?
const phoneCode = $('#loginCountryCodeInput[data-phone-code]');