SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a modal dialog and I want to change some of its properties through javascript. I have found the jquery code


but when I try to use the javascript


it comes back null. I am not sure whether I am converting jquery to javascript wrong or I have the wrong id.

I am using Sharepoint 2010.

share|improve this question

The id of the close button is not just "DlgClose" it is "DlgClose< GUID >". For example, DlgClose355aef3c-ef2f-4293-a7b1-ffa236195624

In your jQuery code, you are using a begins-with selector ^ which gets all elements whose id starts with a particular string. (DlgClose in this case.)

While in your JavaScript code, you are getting all the elements whose id is exactly "DlgClose". document.getElementById checks for that exact id and gets elements if any. That is why you are getting a null value.

I would suggest you stick to jQuery as it will really make life easier for you. But still if you want to perform the same functionality with pure JavaScript, then have a look here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.