0

mainifest.json:

{
    "name": "Search",
    "version": "1.0",
    "manifest_version": 2,
    "description": "Search",
    "browser_action": {
        "default_icon": "search.png",
        "default_popup": "popup.html"
    },
    "content_scripts": [{
        "matches": [
            "<all_urls>"
        ],
        "js": ["jquery-3.1.1.min.js", "content.js"]
    }]
}

popup.html:

<html>
    <head>
        <script type="text/javascript" src="jquery-3.1.1.min.js"></script>
    </head>
    <body>
        <input type="text" id="domain">
        <script type="text/javascript" src="content.js"></script>
    </body>
    </html>

content.js:

$(document).ready(function() {
    $("#domain").change(function() {
        console.log($("#domain").val());
    });
});

The event change input when I typed is not working correctly. For example:

When I type the word test, in the console only show the word test. It should be: t, te, tes, test.

Or when I used alert instead of console.log is not working too, but when I clicked in the popup.html the alert displayed and disappear quickly

tuanptit
  • 353
  • 2
  • 5
  • 14
  • The [`change` event](https://developer.mozilla.org/en-US/docs/Web/Events/change) is working correctly. The behavior you describe is what you get with the [`input` event](https://developer.mozilla.org/en-US/docs/Web/Events/input). – Makyen Jan 20 '17 at 04:36
  • @Makyen Thank you, I changed to `on input` and it's working correctly – tuanptit Jan 20 '17 at 04:40

0 Answers0