jquery trigger method to achieve linkage

  • 2021-01-11 01:53:09
  • OfStack

In this paper, an example describes the jquery trigger linkage method. To share with you for your reference, as follows:

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
  $("#Provinces").change(function (e,cityValue) {
    if ($(this).val() == "1") {
      $("#City").html("<option value='1' > changsha </option><option value='2' > hengyang </option>");
    } else {
      $("#City").html("<option value='1' > wuhan </option><option value='2' > xiangyang </option>");
    if (typeof (cityValue) != "undefined") {
function test() {
  <select id="Provinces" >
    <option value="1" > hunan </option>
    <option value="2" > hubei </option>
  </select><br />
  <select id="City">
    <option value="1" > changsha </option>
    <option value="2" > hengyang </option>
  </select><br />
  <input type="button" value=" Set in Xiangyang, Hubei Province " onclick="test()" />

trigger is known to be asynchronous, and code that executes after trigger may run ahead of it. The code above avoids this point.

Readers who are interested in more jQuery related content can check out the special features of this site: jQuery Drag Effects and Techniques Summary, jQuery Expansion Techniques Summary, jQuery Common Classical Effects Summary, jQuery Animation and Effects Usage Summary, jquery Selection Method Summary and jQuery Common Plugins and Usage Summary

I hope that what this article describes is helpful to jQuery program design.

Related articles: