HTML and CSS Reference
In-Depth Information
<title> Altering Classes on the Fly </title>
<script src=”jquery-1.4.2.min.js” type=”text/javascript” charset=”utf-
<script type=”text/javascript” charset=”utf-8”>
$(function () {
$(“#editable li”).live('click', function () {
$(“#clearList”).click(function (event) {
$(“#addElement”).submit(function (event) {
$(“#editable”).append(“<li>” + $(“#addElement
input[name='liContent']”).val() + “</li>”);
$(“#addElement input[name='liContent']”).val(“”);
<ul id=”editable”>
<p> Click on an item in the list to remove it. </p>
<p><a id=”clearList” href=”#”> Clear List </a></p>
<form id=”addElement”>
<label>New list item: <input name=”liContent” size=”60” /></label>
<input type=”submit” value=”Add Item” />
There are other methods for adding content in different locations in relation to a selected
element. For example, if I change the append() call to prepend() , new items will be
added to the top of the list rather than the bottom. You can also use the before() method
to add content before another element and the after() element to add it after. The differ-
ence is that when you use those methods, the content is placed outside the tags matched
by the selector, rather than inside those tags.
Search WWH ::

Custom Search