Reputation: 1408
I don't know what I'm doing wrong, but I can't get the change()
event to fire.
JS:
<script>
$(document).ready(function () {
$('#Textbox_Positions').change(Function())
alert("test");
})
</script>
HTML:
<input id="Textbox_Positions" type="text" placeholder="Search" style="width: 205px" />
Upvotes: 0
Views: 97
Reputation: 886
The answers for hooking up an element to the change function are correct, but the answer to your question, if you want to test that it works is $('#Textbox_Positions').trigger('change');
.
I have used the changed event in this way to propagate changes through nested, jquery'ed elements that require an internal update() function to fire when the layout changes on one of their descendants.
Upvotes: 0
Reputation: 195972
Javascript is case-sensitive.
Function
should be function
<script>
$(document).ready(function () {
$('#Textbox_Positions').change(function(){
alert("test");
});
});
</script>
plus you have a syntax error by not correctly create a block using {..}
for you functions code..
The whole function() {/*code here*/}
needs to go inside the change
parenthesis.
$('#Textbox_Positions').change(function(){/*code*/});
Just as you do for $(document).ready
Upvotes: 1
Reputation: 26257
You did miss the {} on the function that encloses the alert.
<script>
$(document).ready(function () {
$('#Textbox_Positions').change(function(){
alert("test");
});
})
</script>
Upvotes: 0
Reputation: 20415
Try something like this:
<script>
$(document).ready(function ()
{
$('#Textbox_Positions').on("change", function ()
{
alert("test");
});
});
</script>
Upvotes: 1