jquery - How to give my list of DIV elements a checkbox functionality? -


i have simle html page displays list. each item on list div element (round-corner box) contains data , checkbox.
i'm trying give div functionality of checkbox, meanning when user click div want change color (or display image of v) , when user submits page want item ids checked sent.
here snipet of html:

<!-- item list -->      <div class="container">   <ul class="plainlist">     <c:foreach items="${itemsfrom.itemsonly}" var="item" varstatus="status">                   <li>         <div class="inner">           <img src="resources/images/${item.id}.png">                      <ul class="plainlist">                          <li><h4>${item.title} &trade;</h4></li>                           <li><h5>${item.description}</h5></li>                       </ul>                       <input style="float: right;" type="checkbox" name="itemids" value="${item.id}" />                      <div style="clear: both"></div>                    </div>                  </li>              </c:foreach>         </ul>      </div>  

can me start: jquery? css?. simple examples?

did read jquery api ?
there multiple ways achieve goal me, more efficient use jquery , event click.
in example, you've bind event click on each div have class inner.
syntax :

$(document).ready(function(){     $(".inner").click(function(){         //do stuff     }); }); 

in second part, jquery include function .css() allows set css-property of matched element.
example, if want change background-image of div :

$(document).ready(function(){     $(".inner").click(function(){         $(this).css("background-image","url(path/to/your/image)");     }); }); 

you'll understand snippet of code not reproduce "checkbox functionnality", change background of div once.
should take @ jquery event .toggle().

to you, syntax want :

    $(document).ready(function(){          $(".inner").toggle(             function(){                 $(this).css("background-image","url(path/to/your/image1)");                 },             function(){                 $(this).css("background-image","url(path/to/your/image2)");             }         );      }); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -