"add attribute in select option" Code Answer's
You're definitely familiar with the best coding language Javascript that developers use to develop their projects and they get all their queries like "add attribute in select option" answered properly. Developers are finding an appropriate answer about add attribute in select option related to the Javascript coding language. By visiting this online portal developers get answers concerning Javascript codes question like add attribute in select option. Enter your desired code related query in the search bar and get every piece of information about Javascript code related question on add attribute in select option.
add attribute in select option
<select id="select">
<option value="1" data-foo="dogs">this</option>
<option value="2" data-foo="cats">that</option>
<option value="3" data-foo="gerbils">other</option>
</select>
// JavaScript using jQuery
$(function(){
$('select').change(function(){
var selected = $(this).find('option:selected');
var extra = selected.data('foo');
...
});
});
// Plain old JavaScript
var sel = document.getElementById('select');
var selected = sel.options[sel.selectedIndex];
var extra = selected.getAttribute('data-foo');
Source: stackoverflow.com
All those coders who are working on the Javascript based application and are stuck on add attribute in select option can get a collection of related answers to their query. Programmers need to enter their query on add attribute in select option related to Javascript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about add attribute in select option for the programmers working on Javascript code while coding their module. Coders are also allowed to rectify already present answers of add attribute in select option while working on the Javascript language code. Developers can add up suggestions if they deem fit any other answer relating to "add attribute in select option". Visit this developer's friendly online web community, CodeProZone, and get your queries like add attribute in select option resolved professionally and stay updated to the latest Javascript updates.