我是 jQuery 初学者,这就是我想要做的:
我有一个包含两个<select>控件的表单。他们每个人都有不同的<label>. 我需要将每个文本内容移动到其关联<label>的第一个<option>( ) 。<option value="" selected="selected"><select>
这是我的 jQuery :
jQuery(document).ready(function(){
var CONTACT_FILTER_LABEL = jQuery(".contact-filter option:selected").closest("label").text();
jQuery(".contact-filter option:selected").each(function(){
jQuery(this).html(CONTACT_FILTER_LABEL);
});
});
我想我还需要用<option>相同的内容填充控件的 value 属性。我尝试了很多东西,但仍然无法做到。
jsFiddle 链接(已更新!):http: //jsfiddle.net/y9JaE/27/。
非常感谢您提供的帮助!