Py学习  »  Milan Chheda guest271314  »  全部回复
回复总数  1
7 年前
回复了 Milan Chheda guest271314 创建的主题 » jquery函数不使用Ajax返回/呈现的页面[重复]

当使用 jQuery(html, attributes) .

自jquery 1.8起 ,任何jquery实例方法(方法 jQuery.fn )可以用作传递给的对象的属性 第二个参数:

function handleDynamicElementEvent(event) {
  console.log(event.type, this.value)
}
// create and attach event to dynamic element
jQuery("<select>", {
    html: $.map(Array(3), function(_, index) {
      return new Option(index, index)
    }),
    on: {
      change: handleDynamicElementEvent
    }
  })
  .appendTo("body");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>