0

I am trying to add a custom element to Select html element.

 var sel=document.getElementById("sel1");
  sel.setAttribute("customprop","blabla");

In chrome it works, in IE8 it doesn't.

NO JQUERY

9
  • 1
    You mean custom attribute (not element), right? Anyway, what are you trying to do with that? Commented Nov 3, 2013 at 9:31
  • Maybe you should try to use a jQuery.attr('name', 'value')? Provided that you use jQuery. Commented Nov 3, 2013 at 9:31
  • It should work: msdn.microsoft.com/en-us/library/ie/ms536739(v=vs.85).aspx. Is sel non-null? Commented Nov 3, 2013 at 9:32
  • @Paul Draper, no jquery Commented Nov 3, 2013 at 9:33
  • @yuris, you mean WojciechFrącz, no jquery? Commented Nov 3, 2013 at 9:35

1 Answer 1

2

Check the question: Replace setAttribute with IE compatible script

It seems you need to add doctype on top of your page:

<!DOCTYPE html>

and then the following tag inside your head element to make setAttribute work:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.