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 need to make an application page or a webpart that have a javascript code and i tried to add the jquery i a new project to upload it to the SharePoint but the code didn't work this is the code that i am tried to run the same Visual Studio project

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead"
<script type="text/javascript">

$(document).ready(function () {
$('ul#people > li').css('background-color', '#ADD8E6');

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<div id="myId">
Paragraph before List</p>
<ul id="people">
Paragraph after List</p>
Paragraph inside another div</p>
share|improve this question

You would need to:

  1. Make sure you got jQuery properly loaded. Falak's approach absolutely valid, is but one of the most quicker - you need to make sure you upload your jQuery library in the _layouts/js folder prior to testing. There are other ways to load JQUery, such as using the ScriptLink (see here or a Custom Actions (see here

  2. Check by code if jQuery is really loaded using either

    if (jQuery) {  
    // jQuery is loaded  
    } else  { // jQuery is not loaded }

    //or use this if (typeof jQuery == 'undefined') { // jQuery is not loaded
    } else { // jQuery is loaded }

share|improve this answer
thanks a lot :) – sarah Jun 16 '12 at 15:43
There are many elegant approaches where you can add controls/scripts to pages without modifying the master page, DelegateControls, ScriptLink etc., but it's up to you to decide which suits your application best. – Falak Mahmood Jun 16 '12 at 20:46

First things first, let’s make sure if you are loading a copy of the jQuery script in the application page. For e.g.

<script language="javascript" src="http://yoursite/_layouts/js/jquery-1.7.1.js" type="text/javascript"></script>

share|improve this answer
should i have to upload it in the same application page ?? – sarah Jun 16 '12 at 14:14
deploying the jQuery Script File to Layouts can easily be done via VS2010. In your Right-click your project and add a SharePoint "Layouts" Mapped Folder. Include the jQuery file and you're good to go – Falak Mahmood Jun 16 '12 at 20:39

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.