Margin for select option in IE and chrome is not working
- by Sardor
I am setting a css class to some select options in JS. This class includes margin style. It is working in the FF but not in IE and chrome.
window.onload = function() {
replace('edit-field-region-tid');
replace('edit-tid');
}
function replace(id) {
var i = 0;
var s = document.getElementById(id);
for (i; i < s.options.length; i++) {
if (find(s.options[i].text, id, i)) {
s.options[i].setAttribute("class", "sub_options");
}
}
}
function find(str, id, option_id) {
var i;
var s = document.getElementById(id);
for (i = 0; i < str.length; i++) {
if (str.charAt(i) == '-') {
s.options[option_id].text = str.cutAt(0, "");
return true;
}
}
return false;
}
String.prototype.cutAt = function(index, char) {
return this.substr(index+1, this.length);
}
And CSS:
.sub_options{
margin-left:20px;
text-indent:-2px;
}
Any ideas thanks!