This article describes how to use JavaScript to obtain the values of onclick, onchange, and other events. For more information about how to solve the cascading problem of the drop-down menu, to obtain the content of an event in the HTML Tag, that is, the value, for example, from
To obtain javascript: test ();.
The dish wants to determine the next menu through th
Obtain the values of onclick, onchange, and other events using pure JavaScript. onclickonchange
When you are dealing with the cascading problem of the drop-down menu, you want to obtain the content of an event in the HTML Tag, that is, the value, for example, from
The dish wants to determine the next menu through the information in the event, but this seemingly simple problem makes the dish tangle.
If you
Originally, I wanted to add text content in the text box to change the event action. As a result, I found many javascript code in this area, which was unsatisfactory. Change the mindset to a keyboard button event as follows:
One problem here is that you cannot trigger this event by copying and pasting the content. The following are some related code:
The Code is as follows:
Function fNameChange (){If ($ ('# txtName'). val (). length JQuery ("
The getAttributeNode () method is used here. It obtains attribute nodes and ignores the differences between attributes and events. The specific example is as follows, if you are interested, you can refer to the following: I hope to help you. When you are dealing with the drop-down menu cascading problem, you want to get the content of an event in the HTML Tag, that is, the value, for example, from
To obtain javascript: test ();.
The dish wants to dete
Today the side dishes handle Pull-down menu cascading problems, want to get the content of an event in the HTML tag, that is, the value, such as from Small dishes want to pass the information in the event to determine the next level of the menu, but this seemingly simple question, but let the side of the cake tangled.
A little bit of jquery's kid's shoes might try to get this:
Copy Code code as follows:
$ (document). Ready (function () {
var Onchangevalue = $ ("#city"). attr ("
1. onfocus EventsWhen the input box gets to the focus, it triggers the event, such as modifying the background color of the input box when it gets to the focus. This feature can actually be defined using CSS's pseudo-class: focus.2. onblur EventsThis with the onfocus event idea, when the input box loses focus, triggers the event, such as changing the input text uniformly to lowercase3. OnChange EventsThe occurrence of this event requires 2 conditions:
tangle, another method of using pure JavaScript to achieve the acquisition was found.The specific code is as follows:
Copy Code code as follows:
$ (document). Ready (function () {
var onchangevalue = document.getElementById ("City"). GetAttributeNode ("onchange"). NodeValue;
alert (onchangevalue);
});
Simply put, here is the GetAttributeNode () method, which gets the attribute node, ignoring th
Today the side dishes handle Pull-down menu cascading problems, want to get the content of an event in the HTML tag, that is, the value, such as from
Small dishes want to pass the information in the event to determine the next level of the menu, but this seemingly simple question, but let the side of the cake tangled.
A little bit of jquery's kid's shoes might try to get this:
Copy Code code as follows:
$ (document). Ready (function () {
var Onchangevalue = $ ("#city"). att
Onkeypress occurs when a keyboard key is pressed or held down
Onchange occurs when the content of a field changes
OK, let's go further. If you want to validate the character number limitation of one textarea control, which one you shoshould choose?
I told you that the onchange is better. Because if you use Copy text from somewhere to this control, the onkeypress will not be converted Ted; while, the
Javascript|select When we use the Select OnChange event, we often encounter the problem that the onchange event is not triggered when the same item is selected consecutively. The onchange event of the Select is this. You have to have change ( Change) in order to trigger the event ....
After mastering its characterist
1. onchange and its onpropertychange, oninput
In IE, you can use onpropertychangel to immediately trigger the listener,Oninput can be used in FF, but events must be bound using the addEventListener method recommended by w3c.Http://www.jb51.net/article/25275.htm2. The input tag is rarely used. Today, the developer uses the button to describe how to use the same tag as the submitted tag in ff. the user can check the manual and find that the type attrib
1. onchange and its onpropertychange, oninputIn IE, you can use onpropertychangel to immediately trigger the listener,Oninput can be used in FF, but events must be bound using the addEventListener method recommended by w3c.Http://www.jb51.net/article/25275.htm2. The input tag is rarely used. Today, the developer uses the button to describe how to use the same tag as the submitted tag in ff. the user can check the manual and find that the type attribut
This article mainly introduces the performance and solution of the onchange event in IE and FF. If you need it, you can refer to it, I hope it will be helpful to you. In a recently developed project, there is a checkbox on the page. When you select or cancel this checkbox, A jsonp request will be sent to the backend. At that time, the implementation was to add an onchange event for this checkbox, but the re
When onchange is used in the text box input box, there is an obvious deficiency. The event will not be triggered with the text input, but will be triggered when the text box loses the focus (onblur). That is, there is no instant!
In IE, onpropertychange can be used to replace the onchange event. This event can be triggered immediately when there is any change in the text box.
In this way, the problem is s
1.onchange and its onpropertychange,oninputIn IE can use Onpropertychangel to trigger the monitor immediately,
Oninput can be used under FF, but you must use the AddEventListener method recommended by the consortium to bind events.
Http://www.jb51.net/article/25275.htm
2. Rarely used in general use input tags, today development that use Button said under the FF how and submit the same, check the manual found button has the Type attribute value: Su
Here is the main use of GetAttributeNode () This method, it gets the attribute node, ignoring the difference between the attributes and events, such as the following, interested friends can refer to the next ha hope to be helpful to everyoneToday, when dealing with drop-down menu cascading issues, you want to get the content of an event in the HTML tag, which is the value, such as from A little bit of jquery's children's shoes may try to get:$ (document). Ready (function() { var onchangevalue
Change the mindset to a keyboard button event as follows:
One problem here is that you cannot trigger this event by copying and pasting the content. Below are some of the relevant
Code :
Copy code The Code is as follows: function fnamechange (){
If ($ ('# txtname'). Val (). length Jquery ("# checksta" ).html ("the name is too short! ").Css (" color "," Red ");
} Else {
Myajax ();
}
}
The following are some content for online search:Copy codeThe Code is as follows: // onload () event$ (Function
The onchange event occurs when the domain content changes.
The following example shows that when you enter lowercase letters in the input box and press enter, you will find that the content of the domain has changed to uppercase.
Change the mindset to a keyboard button event as follows:One problem here is that you cannot trigger this event by copying and pasting the content. The following are some related code:Copy codeThe Code is as follows:Function fNameChange (){If ($ ('# txtName'). val (). length JQuery ("# checkSta" ).html ("the name is too short! ").Css (" color "," red ");} Else {Myajax ();}} The following are some content for online search:Copy codeThe Code is as follows:// Onload () event$ (Function () {// The e
Select
When we use the onchange event of Select, we often encounter the problem of not triggering the onchange event when the same item is selected consecutively. The onchange event of the Select is this. You have to have change to trigger the event ....
After mastering its characteristics, the corresponding solution is also very simple.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.