Closed ar-post closed 7 years ago
Usage
<li class="mdl-menu__item" data-value="G">Germany</li>
<li class="mdl-menu__item" data-value="B">Belarus</li>
and then
$( '#sample1' ).value; // Germany
$( '#sample1' ).getAttribute( 'data-value' ); // G
Trimming should provide for cases like this
<li class="mdl-menu__item" data-value="G">
<strong>Germany</strong>
</li>
Actually this already works, but you should use 'data-val', not 'data-value', attribute. Thank you for your request.
Use data-value attribute to keep real input value not only caption Also value string is fixed by trimming it