Add items to listview

Description

The following code shows how to add items to listview.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!-- ww w. j a  va 2 s. c o  m-->
$('a.more').click(function() {
    var $content = $('<li><a href="">Another item</a></li>');
    $('#updates').append($content).listview('refresh');
});
});//]]>  
</script>
<link rel="stylesheet"
  href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script
  src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
</head>
<body>
  <div data-role="page">
    <div data-role="content">
      <ul id="updates" data-role="listview" data-theme="a">
        <li><a href="">Acura</a></li>
        <li><a href="">Audi</a></li>
        <li><a href="">BMW</a></li>
      </ul>
      <br /> <br /> 
      <a class="more" href="#add" data-role="button">Add
        another</a>
    </div>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme