JQuery cascaded operations bind event instances

  • 2020-03-30 03:50:50
  • OfStack

Cascading action binding events is a very useful trick of jQuery, and this article implements it as an example. Share with you for your reference. Specific methods are as follows:

The example described in this paper is mainly to achieve a list of jQuery operations, according to the category of schools, click schools appear departments, click departments appear majors, and then link to the professional application page.

The specific function code is as follows:


$("li.university").click(function(){
  var id = $(this).attr("rel");
  $.get("data.aspx?type=u&id="+id ,
  function(html){$("#universityselect").html(html);});
});
$("li.universityselect").click(function(){
  var id = $(this).attr("rel");
  $.get("data.aspx?type=s&id="+id ,
  function(html){$("#coursetype").html(html);});
});
$("li.course").click(function(){
  //var id = $(this).attr("rel");
  alert("dd");
  //$.get("data.aspx?type=p&id="+id ,
  //function(html){$("#sourseselect").html(html);});
});

I believe that this article has a certain reference value for your jQuery programming.


Related articles: