Call jQuery to SharePoint page using a Content Editor web part
Check out Best Alternative to InfoPath -> Try Now
This SharePoint 2010 tutorial, we will discuss how to call jQuery into a SharePoint page using the content editor web part. In one of my previous article, I have explained about how to deploy jQuery to SharePoint using solution package. After you deploy jQuery to SharePoint, it is time to call jQuery to a SharePoint page.
There are different ways you can call jQuery libraries to SharePoint page like:
- By using a Content Editor web part
- By using custom actions
- By dynamically through code
- By adding the script to the master page etc.
This is one of the simplest approaches, But jQuery will be available on the same page where the Content Editor web part is added, it will not affect any other pages. This can be used in a Sandboxed environment.
Call jQuery through content editor web part in SharePoint
Follow below steps to call jQuery through content editor web part in SharePoint.
First, edit the page on which you want to call the jQuery libraries. Then on one of the webpart zone click on Add a Web Part.
Then from the Media and Content category section select Content Editor web part and click on Add as shown in the figure below.
Then in the content editor web part Click on “Click here to add new content” to edit the contents of the web part.
In the Ribbon, go to the Format Text section, select HTML in the Markup group, and choose HTML Source as shown in the figure:
Now in the edit HTML source dialog box paste the below line:
Now Save and Publish the page.
After this step, the jQuery will be available to the SharePoint page.
Copy the text file and put it inside the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\STYLES folder.
Open the page where you want to add Content Editor Web Part and edit the page. After that in the edit mode click on Add web part and from the Ribbon select the Media and Content web part category and select Content Editor web part and then click on Add.
Click on OK.
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.