Clear text input content

Description

The following code shows how to clear text input content.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.2.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css">
<script type='text/javascript'
  src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>
<style type='text/css'>
span {<!--from  w  ww.  ja  v a2  s . c  om-->
  pointer: cursor;
}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
    $('#X').click(function(){
       $(this).prev().val("").focus()
    })
});//]]>  
</script>
</head>
<body>
  <div data-role="page">
    <div data-role="content">
      <input type="search" name="search" id="search-basic"
        value="something" /> <br /> <br /> <br /> 
      <input type="text"
        name="name" id="basic" value="Text wothout X button" /> 
      <span id='X'>X</span>
    </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