0

I have a dropdown selection tag as

    <select id="_users_add_dropDown" class="form-control style-scope view-work-organizer" style="width: 100% !important; bottom: 0;" required="">
  <option value="View" class="style-scope view-work-organizer" selected="">
                        VIEW</option>
                  <option value="Edit" class="style-scope view-work-organizer">
                EDIT</option>
         <option> </option></select>

I want to add at end of <select id="_users_add_dropDown" class="form-control style-scope view-work-organizer" style="width: 100% !important; bottom: 0;" required="">

into

`<select id="_users_add_dropDown" class="form-control style-scope view-work-organizer" style="width: 100% !important; bottom: 0;" required="" onclick=alert('test');>`

I want to do using JavaScript. I tried

var x = document.getElementById("_users_add_dropDown");
        var option = document.createElement('option');
option.text = "alert('1'); </script>
";
 x.add(option);

This is not what i want as it add alert('1') as drop-down option I want it to appear at end of html tag. thanks.

1 Answer 1

1

you are asking to add an attribute to the html element, so you should not use the createElement method.

have you tried this ?

    document.getElementById("_users_add_dropDown").setAttribute('onclick', "alert('test')");
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.