title: How to change the style element of a div with jQuery
body: <p>I am trying to change the style values of a <code>div</code>'s <code>style</code> element with jQuery. Mainly I just want to change the position of the background image, which is a sprite. The following is my main code, you can also view it on jsFiddle: <a href="http://jsfiddle.net/PvTe3/2/" rel="nofollow">http://jsfiddle.net/PvTe3/2/</a></p>
  
  <pre><code>$("#SelectAllBtn").on('click', function ()
  {
      $("#departmentList input[type=checkbox]").each(function()
      {
  
          alert("moo");
  
          $(this).parent().css('background-image', 'http://localhost:9060/content/img/checkbox_png.png');
          $(this).parent().css('width', '19px');
          $(this).parent().css('height', '19px');
          $(this).parent().css('cursor', 'pointer');
          $(this).parent().css('0px', '0px');
  
      })
  });
  </code></pre>
  
  <p>The markup I am trying to change is the following:</p>
  
  <pre><code>&lt;input type="button" id="SelectAllBtn" value="vælg alle" /&gt;
  
  &lt;div id="departmentList" class="bgWhite withBorder" style="overflow-y: scroll"&gt;
          &lt;div&gt;
          &lt;table class="department_table" cellspacing="0" id="ContentPlaceHolder1_BaaMainContent_dl_gv" style="border-width:0px;border-style:None;width:100%;border-collapse:collapse;"&gt;
              &lt;tbody&gt;&lt;tr&gt;
                  &lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl00$ContentPlaceHolder1$BaaMainContent$dl$gv','Sort$Name')"&gt;Department&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;Included&lt;/th&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Hybenparken&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                  &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="13" checked="checked" style="display: none;"/&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Granparken&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="14" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Blommehaven&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="17" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Bodsbjergvænget 1&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="18" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Hybenparken Tagboliger&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="19" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Lundetoften&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="27" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Lunden&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="35" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Bodsbjergvænget 3&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="36" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Bodsbjergvænget 4&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="37" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Kastanielunden&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="38" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Skelbækparken&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="43" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Hybenvang&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="50" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Vestergade 4-22&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="52" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Vestergade 24-32&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="53" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Vestergade 7-25&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="54" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Nygade 10-13,Østerg.33-39,38-44&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="55" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Østparken 2-8&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="56" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Østergade 71-113&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="57" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Søndermarken&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="58" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Dalvænget&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="59" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Herluf Trollesvej&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="60" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Nørreled 9-29&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="116" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Mosevang 33-35&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="117" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Bent Grubbesvej, Marievej&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="118" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Østerled 27-33&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="119" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Jørgen Rudsvej&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="120" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Svinget 2-12 - Isefjordsvej 11-16&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="121" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Riffelhavevej 19-35&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="122" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Marievej, Østerled&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="123" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Borgmestergårdsvej 2-16&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="124" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Anders Larsensvej-Kappellanvej-Sejerøvej&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="125" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Karensmindevej&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="126" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Anders Larsensvej 40-46&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="127" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Bjergmarken&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="128" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Kasernen&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="129" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Stillidsvej&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="130" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Skibby&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="131" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Kløvermarksvej 19-21&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="132" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;&lt;tr class="table_row_custom"&gt;
                  &lt;td&gt;Kastaniegården&lt;/td&gt;&lt;td align="center" style="width:40px;"&gt;
                          &lt;div class="cbInclude styledCheckbox" style="background-image: url(http://localhost:9060/content/img/checkbox_png.png); width: 19px; height: 19px; cursor: pointer; background-position: 0px -19px;"&gt;&lt;input type="checkbox" class="cbInclude" data-recid="133" checked="checked" style="display: none;"&gt;&lt;/div&gt;
                      &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;&lt;/table&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>