Target processingFunction is selectAttr(test)
1. Directly pass the given parameters such as:
onclick="selectAttr('1'); onclick="selectAttr('a');
2. Pass a certain attribute Value
<input type="text" id="nameId" name="typeName"> onclick="selectAttr(typeName.value); onclick="selectAttr(nameId.value);
3. Pass this object
onclick="selectAttr(this);
Get the corresponding option value through this object: this.value or this.name;
If yes Custom attributes can be obtained in the following ways:
var divs=document.getElementById("typeName1"); var x=divs.getAttribute("code");
code is a custom attribute.
jqery method to obtain:
$("#typeName").attr("value"); var typeName=$("#sel").find("option:selected").attr("code");
The above is the detailed content of HTML passes parameters to js through events detailed explanation and examples. For more information, please follow other related articles on the PHP Chinese website!