Change text input value with anchor element

Description

The following code shows how to change text input value with anchor element.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.1.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>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!--  w  ww. j a  v  a 2 s. com-->
    var currentValue = 1;
    $("#minus, #plus").click(function(){
        currentValue = ($(this).attr('id')=='plus') ? currentValue + 1 : currentValue - 1;
        $('#value').val(currentValue);
    });
});//]]>  
</script>
</head>
<body>
  <div data-role="page" id="home">
    <div data-role="content">
      <a id="minus" href="#">-</a> 
      <input type="text" id="value" name="days" value="1" /> 
      <a id="plus" href="#">+</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