Skip to main content
Commonmark migration
Source Link

###Delegated Alternative

Delegated Alternative

In case anyone is using the delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

###Delegated Alternative

In case anyone is using the delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

Delegated Alternative

In case anyone is using the delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

deleted 3 characters in body
Source Link
DanielST
  • 14.2k
  • 7
  • 46
  • 67

###Delegated Alternative

In case anyone is using a morethe delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

###Delegated Alternative

In case anyone is using a more delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

###Delegated Alternative

In case anyone is using the delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

formatting, title, link
Source Link
DanielST
  • 14.2k
  • 7
  • 46
  • 67

###Delegated Alternative

In case anyone is using a more delegated approachdelegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

DemoJSFiddle Demo

In case anyone is using a more delegated approach, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

Demo

###Delegated Alternative

In case anyone is using a more delegated approach for their listener, use e.target (it will refer to the select element).

$('#myform').on('change', 'select', function (e) { var val = $(e.target).val(); var text = $(e.target).find("option:selected").text(); //only time the find is required var name = $(e.target).attr('name'); } 

JSFiddle Demo

Source Link
DanielST
  • 14.2k
  • 7
  • 46
  • 67
Loading