onchange

how to change image onclick javascript function?

旧城冷巷雨未停 提交于 2019-11-28 01:57:43
问题 I got a problem, I tried several times but result is always same, I don't know what's wrong with my code. If you click on right image, it will change to left image, but if you click on left image, it wont change to right image, why? here is code: function changeImage() { if (document.getElementById("changer").src == "imgs/left.gif") { document.getElementById("changer").src = "imgs/right.gif"; } else { document.getElementById("changer").src = "imgs/left.gif"; } } and image src code here: <img

What is best way to perform jQuery .change()

北战南征 提交于 2019-11-28 00:00:39
I have 2 separate scripts that essentially do the same thing. I built them over time and just discovered I am using a couple different means to get to the same result. I want to standardize and use the best practices method in both cases. One way I test a change event is this: $('input[name="status"]').change(function() {}); Another way I am testing a change event is this: $("#email").bind("change", function(e) {}); Which way is best? What is the difference between the 2? Thanks for helping me understand this. Before jQuery 1.7, change() was simply a short cut for bind("change") . As of 1.7

Chrome file upload bug: on change event won't be executed twice with the same file

你说的曾经没有我的故事 提交于 2019-11-27 21:09:36
I am working on this html5 file uploader plugin but it has a bug on Google Chrome which I can't understand and fix it. It works fine on Firefox. jsfiddle link The problem is that you cannot upload the same file twice from your desktop. When you first click, select, and hit OK to upload a file from your desktop, it should alert a message, for instance '.button-1' - depends on which upload button you click. Then if you try to upload the same file again, this line of code won't be executed anymore, $(".upload-file",object_parent).change(function() { ... ... alert($cm.selector); }); Any idea what

Jquery .change() function not working with dynamically populated SELECT list

好久不见. 提交于 2019-11-27 20:29:14
I have a select field that is dynamically populated with an ajax call that simply returns all the HTML select options. Here is the part of the PHP that just echo's the select tags and dynamically fills out each option/value. echo "<select name='player1' class='affector'>"; echo "<option value='' selected>--".sizeof($start)." PLAYERS LOADED--</option>"; foreach ($start as $value) { echo "<option value='".$value."'>".$value."</option>"; } echo "</select>"; } After this list is populated, I'm trying to call a change event, so that whenever the default option is changed in the SELECT list or in a

jQuery textbox.val('xxxx') not causing change to fire?

烈酒焚心 提交于 2019-11-27 19:36:17
I have the following jQuery code in place on my page: var isChanged = false; $(document).ready(function() { $('.change').change(function() { isChanged = true; }); }); I am using a plugic that modifies the value of the text box it is linked to using: target.val('xxxx'); the text box in the html (from asp.net) is: <input name="ctl00$cphHolder1$rptFlex$ctl01$txtLeftRank" type="text" value="52°" id="ctl00_cphHolder1_rptFlex_ctl01_txtLeftRank" class="change atiselector" /> When the value of the text box is changed using code, the change is not firing. If I type in the text box, the change fires.

ngChange-like functionality for the entire form

允我心安 提交于 2019-11-27 19:17:44
I would like to do an equivalent of ng-change for the entire form whenever there is a change in one of its input fields. I know that since AngularJS 1.3 I have the debounce option but it applies only for a single input. I'm looking for a "debounce"/"on change" functionality that will apply for the entire form. There isn't a built-in way to do ng-change for a form. It may not even be needed, because if you organized your view model properly, then your form inputs are likely bound to a certain scope-exposed property: $scope.formData = {}; and in the View: <form name="form1"> <input ng-model=

jQuery onchange/onfocus select box to display an image?

丶灬走出姿态 提交于 2019-11-27 19:11:36
I need some help finding a jQuery plugin which will allow me to display an image preview from a select list of images - onfocus/onchange.. Example: <select name="image" id="image" class="inputbox" size="1"> <option value=""> - Select Image - </option> <option value="image1.jpg">image1.jpg</option> <option value="image2.jpg">image2.jpg</option> <option value="image3.jpg">image3.jpg</option> </select> <div id="imagePreview"> displays image here </div> Has anyone come across something like this? I've tried searching for it to no avail.. Thank you! I'm not sure you need a plugin to deal with this:

iOS select onchange not firing

≡放荡痞女 提交于 2019-11-27 18:50:50
Does anyone know any workarounds for this? I'm trying to use a select element for navigation. It looks something like this; <select onchange="window.location=(this.options[this.selectedIndex].value)"> It works on all desktop browsers and it also works on my WP7 phone. It doesn't work on my iPhone (iOS 5.0). iOS tends to not fire change events when you change the value of their inputs. I've documented this in more depth at the Device-Bugs tracker . The workaround is to bind to the blur event instead. In the above example, use onblur and you'll be all set. <select onblur="window.location=(this

How to fire JQuery change event when input value changed programmatically?

倖福魔咒の 提交于 2019-11-27 07:43:26
问题 I want to fire the JQuery change event when the input text is changed programmatically, for example like this: $("input").change(function(){ console.log("Input text changed!"); }); $("input").val("A"); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type='text' /> But it doesn't work. How can I make this work? 回答1: change event only fires when the user types into the input and then loses focus. You need to trigger the event manually using change

Use onchange in a div

落花浮王杯 提交于 2019-11-27 07:39:08
问题 Is it possible to use onchange event in a <div> ? Because my <div> changes its text inside. Can I do something like this? <div id="name" onchange="calculateTotal();"></div> 回答1: Since you say you're using AJAX, why not execute the function when you update the text. I'm not sure if you use any library, but in case it's jQuery just do: $.ajax({ ..., success: function() { ... other things ... ... setting div text ... calculateTotal(); } }); 回答2: No; the onchange attribute is only applicable to