我正在编写一个小脚本,我注意到一些有重复元素的东西。在这种情况下$('#theSelect1 ..')
重复,我想避免它。
$('#theSelect1').change(function(){
//console.log ($(this));
console.log(
$("#theSelect1 option:selected").text() // is there a way to change #theSelect1 to be $(this) inside this statement? I try not to repeat things.
);
})
这是 HTML
<select id="theSelect1">
<option value="foo" selected="selected">1</option>
<option value="bar">2</option>
<option value="foobar">3</option>
谢谢