Get text input id after clicking

Description

The following code shows how to get text input id after clicking.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type="text/javascript"
  src="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.css">
<script type='text/javascript'>
$(document).ready(function () {<!--from  w ww.j a  v  a  2 s  .c  om-->
    $("#user-form").on("click", 'input[type="text"]', function () {
        console.log("Clicked element with id: " + this.id);
    });
});
</script>
</head>
<body>
  <div data-role="page" id="operator-modify" data-theme="b">
    <div data-role="content">
      <form id="user-form">
        <label for="user-id-name">ID:</label> 
        <input type="text" name="user-id-name" id="user-id-m" data-clear-btn="true" /> 
        <label for="user-title-name">Name:</label> 
        <input type="text" name="user-title-name" id="user-title-m" data-clear-btn="true" />
        <label for="user-role-name">Role:</label> 
        <input type="text" name="user-role-name" id="user-role-m" data-clear-btn="true" />
      </form>
    </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