I want to use jQuery in my SP2010 hello world web part which pops up "Hello world" using jQuery. What do I have to do? I know I can do this with JavaScript, but I want to learn about jQuery in web part development.

2 Answers 2


SharePoint Site doesn't support JQuery from scratch. You have to add it manually. It can be done in several ways:

Step 1. Adding JQuery :

1) Deploy JQuery as a custom feature.


2) Upload JQuery as a simple file to the document library.

Step 2. Adding reference to the JQuery :

1.1) Create custom master page with reference to the JQuery.

1.2) Create web site based on the custom master page.


2) Add Content Editor web part to the page. In the web part's properties specify the link to the file.

However to show Dialogue in SP 2010 you should use SP.js. Just add the reference to SP.js in the page and call SP.UI.ModalDialog.showModalDialog() function in JavaScript.


I am not sure what you're going to learn by doing this over and above just using jQuery on a non-SharePoint html page but...

  • Go to a web part page or wiki page you've setup.
  • Select Site Actions > Edit Page Click "Add a web part"
  • Select Media and Content > Content Editor
  • Select “Click here to add new content” On the ribbon select Html > Edit HTML Source

Sp2010 Foundation CEWP Edit HTML Source

Then paste the javascript/jquery you want to put on the page.

To get inspiration on what you can do with javascipt and SharePoint start with Christophe's blog + see also JQuery Tutorials site

  • JUST an FYI...New Content Editor WebPart (2010) strips out all the script added to the HTML source. Only Option left is to create a htm or txt file in any doc lib and link the Content Editor WebPart to it.
    – Vamsi
    Commented Jul 5, 2011 at 14:40
  • No it doesn't. If you try and put script directly into a wiki page (even when using source) then yes it will - but if you put it into a CEWP it does't. Don't take my word for it - sympmarc.com/2011/03/29/…
    – Ryan
    Commented Jul 6, 2011 at 11:37

Your Answer

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

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