title: jQuery Alert working in HTML, not working when added to SharePoint CEWP
body: <p>It works on my fiddle <a href="http://jsfiddle.net/JustJill54/XFaaG/11/" rel="nofollow">http://jsfiddle.net/JustJill54/XFaaG/11/</a>, but does not when I add jQuery code to CEWP.
  (FYI. I am only putting jQuery in CEWP for proof of concept.) 
  Only difference when I view src in the result on the fiddle, is Window.Load() event is there, so I tried adding that event to my CEWP, but alert still does not work.</p>
  
  <p>Here's code from CEWP</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(window).load(function(){
  
  $(document).ready(function() {
      $("tr.reqDet").hide();
      $("tr.anon").hide();
      $("tr.actDet").hide();
  
      // Attach to the focusout event of the select, if that's when
      // you want to check the value
      $("select[title='organizationalElement']").focusout(function() {
          // Now see if it's the value you want
          if ($(this).val() === 'idk') {
              alert("If no organizational element is selected, additional time may be required to route this request");
          } //close if
      $("select[title='requestType']").change(function() {
          $(".reqDet").toggle($(this).val() !== "");
      }); //close requestType
      $("select[title='anonymous']").change(function() {
          $(".anon").toggle();
      }); //close anonymous
      $("select[title='action']").change(function() {
          $(".actDet").toggle($(this).val() !== "");
      }); //close action
      }); //close select.focusout
  }); //close doc.ready
  }); //close window.load
  &lt;/script&gt;
  </code></pre>
  
  <p>UPDATE: I have commented out all of my logic and just tried to get AN alert to show when the page loads and I still have not been able to get it to work.</p>
  
  <p>UPDATE2: I have created an .html page with same controls as my SharePoint page, and added jQuery script to show alert on page load, and even that one is working, but .aspx page with SharePoint:FormField controls is not working.</p>
  
  <p>UPDATE3: I have referenced a javascript tutorial and revised my script. The main differences are that the NOT EQUAL operators have been changed to != instead, and I have commented out the Window.load event. Here is my revised script:</p>
  
  <pre><code>//$(window).load(function(){
  
  $(document).ready(function(){
  
      $("tr.reqDet").hide();
      $("tr.anon").hide();
      $("tr.actDet").hide();
  
      $("select[title='organizationalElement']").focusout(function() {
  
          if ($(this).val() === 'idk') {
              alert("If no organizational element is selected, additional time may be required to route this request");
          } // close if
  
      $("select[title='requestType']").change(function() {
          $(".reqDet").toggle($(this).val() != "");
      }); //close requestType.change
  
      $("select[title='anonymous']").change(function(){
        $(".anon").toggle();
      }); //close anonymous.change
  
      $("select[title='action']").change(function(){
          $(".actDet").toggle($(this).val()!= "");
      }); // close action.change
  
      });//close select.focusout
  
  }); // close doc.ready
  //}); // close window.load
  </code></pre>
  
  <p>UPDATE4: I used firebug to get the val of the selector, and realized it is not returning 'idk' (as specified by SP's list item's value), but returning "I don't know" instead. Which raises another issue/reminds me I will need to escaping the apostrophe (') in don't. Anyways, still working out the kinks...</p>
  
  <p>UPDATE5: @Janis- I am not able to see my script on the script tab in firebug... So I guess that mean's it isn't being executed. </p>
  
  <p>BTW. Here's the state of the script after UPDATE4.</p>
  
  <pre><code>$(window).load(function(){
  
  $(document).ready(function(){
  
      $("tr.reqDet").hide();
      $("tr.anon").hide();
      $("tr.actDet").hide();
  
      $("select[title='organizationalElement']").focusout(function() {
  
          if ($(this).val() === "I don\'t know") {
              alert("If no organizational element is selected, additional time may be required to route this request");
          } // close if
  
      $("select[title='requestType']").change(function() {
          $(".reqDet").toggle($(this).val() != "");
      }); //close requestType.change
  
      $("select[title='anonymous']").change(function(){
        $(".anon").toggle();
      }); //close anonymous.change
  
      $("select[title='action']").change(function(){
          $(".actDet").toggle($(this).val()!= "");
      }); // close action.change
  
      });//close select.focusout
  
  }); // close doc.ready
  }); // close window.load
  </code></pre>
  
  <p>Any idea why? I thought I was using pretty general events that are always called (doc.ready, window.load). </p>
  
  <p>UPDATE6: Geez...FINALLY! Guess the 6th time's the charm. I'm definitely going to fill everyone in on what worked for me....
  Anyways, revised script is as follows: </p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt; 
  &lt;script type="text/javascript"&gt; 
  $(window).load(function(){  
    $(document).ready(function(){      
       $("tr.reqDet").hide();     
       $("tr.anon").hide();     
       $("tr.actDet").hide();      
     $("select[title='organizationalElement']").focusout(function() {          
       if ($(this).val() === "I don\'t know") {             
          alert("If no organizational element is selected, additional time may be required to route this request");         
       } // close if      
        $("select[title='requestType']").change(function() {         
          $(".reqDet").toggle($(this).val() != "");     
        }); //close requestType.change      
        $("select[title='anonymous']").change(function(){       
          $(".anon").toggle();     
        }); //close anonymous.change      
        $("select[title='action']").change(function(){         
          $(".actDet").toggle($(this).val()!= "");     
        }); // close action.change      
     });//close select.focusout  
    }); // close doc.ready 
  }); // close window.load 
  &lt;/script&gt;
  </code></pre>
  
  <p>Instead of pasting directly into CEWP, I have it uploaded as .js file to a folder I created called SiteAssets (in the event we migrate to SPD2010), and am calling said file ...js via the CEWP's content link. Used firebug to verify script was being loaded. </p>
  
  <p>So, some things I've learned about getting this jQuery script to work for me in my SP page-</p>
  
  <ol>
  <li>Do not assume you know what val is being returned-- use console tab of firebug to get EXACT results  </li>
  <li>Check your syntax  </li>
  <li>Even when referencing jQuery code in a ...js file, make sure that it starts w/ requisite  tags, o.w. you may end up with your script being inserted as text at the bottom of the page
  Hope this helps!  </li>
  </ol>