Desktops Made to Order(assembled) HP/Compaq IBM Lenovo etc Servers Made to Order(assembled) Compaq IBM etc Laptops HP/Compaq IBM Lenovo Sony Dell etc 小提琴 $("select[name='qwe'] option").click(function () { $(this).each(function () { var label = $(this).parent().parent().parent().find('label').text(); var text = $(this).text(); alert('option text is ' + text); alert('label text is ' + label); }); }) UPDATE 正如@mplungjan建议FIDDLE $("select[name='qwe']").change(function () { $(this).each(function () { var text1 = $(this).find('option:selected').text(); var label1 = $(this).find('option:selected').parent().parent().parent().find('label').text(); alert('option text is ' + text1); alert('label text is ' + label1); }); UPDATE 没有.parent()和.closest('div.classnameoftheparentdiv') 小提琴 $("select[name='qwe']").change(function () { $(this).each(function () { var text1 = $(this).find('option:selected').text(); var label1 = $(this).find('option:selected').closest('div.form_field').find('label').text();//HERE parent div that contains the label has a class form_field alert('option text is ' + text1); alert('label text is ' + label1); }); }) 使用jQuery进行XML解析 ajax通过jquery提交多个表单 d3圆环图在移动视图中不完全可见手动编辑日期或清除日期时,bootstrap datepicker更改日期事件不会启动Gupshup Chat Web Widget重定向问题2d弹丸轨迹?Highcharts csv数据系列以空值开头比较两个json数组Mvvm支持自定义kendo ui小部件用户将鼠标hover在链接上2秒钟后执行function仪表板跨域AJAX与jquery Go! Interesting Posts Sketch.js pageX未定义错误当表更改内容时调用Javascript函数如何从jquery对象中删除dom元素窗口滚动到某些位置时触发事件使用javascript选择帧上下文Framework7日历事件使用AJAX onMonthAdd加载Jquery添加类并在页面重新加载时保留动态设置值后更改事件未触发动态引用Javascript数组名称而不使用Eval?如何多次调用函数?
小提琴
$("select[name='qwe'] option").click(function () { $(this).each(function () { var label = $(this).parent().parent().parent().find('label').text(); var text = $(this).text(); alert('option text is ' + text); alert('label text is ' + label); }); })
UPDATE
正如@mplungjan建议FIDDLE
$("select[name='qwe']").change(function () { $(this).each(function () { var text1 = $(this).find('option:selected').text(); var label1 = $(this).find('option:selected').parent().parent().parent().find('label').text(); alert('option text is ' + text1); alert('label text is ' + label1); });
没有.parent()和.closest('div.classnameoftheparentdiv')
.parent()
.closest('div.classnameoftheparentdiv')
$("select[name='qwe']").change(function () { $(this).each(function () { var text1 = $(this).find('option:selected').text(); var label1 = $(this).find('option:selected').closest('div.form_field').find('label').text();//HERE parent div that contains the label has a class form_field alert('option text is ' + text1); alert('label text is ' + label1); }); })