我有一个生成的选择字段,有2个选项,比如
<div class="PlentyFormContainer">
<div class="PlentyFormContainer ArticleAttrTd_0 PlentyWebAttributeTitle">Rollen/Gleiter</div>
<div class="PlentyFormContainer ArticleAttrTd_1 PlentyWebAttributeSelect">
<select onchange=" this.blur();
switchImage(this.value ,'378_0', '378', aAttribute_Image_Values_378);
priceChangeOnMarkup(this.value, '2', '0', 'price_dynamic_0_378', aAttribute_Markup_Values_378, aCurrent_Markups_378, oldPrice_378);
"
class="ArticleAttrSelect PlentyAttributeSelect_1" id="attr_row_0_378_2"
name="ArticleAttribute[0][378][53]"><option value="" class="PlentyAttributeOption">-- bitte wählen --</option><option value="1364" class="PlentyAttributeOption PlentyAttributeOption_1364">Rolle weich gebremst für harte Böden </option><option value="1363" class="PlentyAttributeOption PlentyAttributeOption_1363">Rolle hart gebremst für Teppichboden </option>
</select>
</div>
</div>
这整个div选择事物是由这些元素生成的:
<div class="plentyAttributeSelectWrapper">
<div class="plentyAttributeSelectWrapperTitle"><span>Rollen/Gleiter</span>
</div>
<div class="plentyAttributeSelectWrapperContent plentyAttributeSelectHasDropdown">
<div>
<div class="plentyAttributeSelectedValue">
<span class="plentyAttributeSelectedValueName">Rolle weich gebremst für harte Böden</span>
<span class="plentyAttributeSelectedValueMarkup plentyAttributeSelectValueMarkup"></span><span class="plentyAttributeSelectedArrow">
<span></span></span>
<span class="clear"></span>
</div>
<div class="plentyAttributeSelectListWrapper">
<ul>
<li>
<div class="plentyAttributeSelectValue">
<a><span class="plentyAttributeSelectValueName">Rolle hart gebremst für Teppichboden</span>
<span class="plentyAttributeSelectValueMarkup"></span></a>
</div>
</li>
<li>
<div class="plentyAttributeSelectValue">
<a><span class="plentyAttributeSelectValueName">Rolle weich gebremst für harte Böden</span>
<span class="plentyAttributeSelectValueMarkup"></span></a>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
如果我尝试在更改选项时强制发出警告,则没有反应。
答案 0 :(得分:1)
您生成的代码很好。
它显示警告,如此处所示:http://jsfiddle.net/ww5Rr/
<select onchange="this.blur(); alert('hi! \nAlert is working...');" >
也许您调用的函数(未在此处发布)内部存在破坏警报的功能。
尝试在blur()调用之后立即发出提醒。
答案 1 :(得分:0)
我尝试用jquery抓取select:
$('div.PlentyFormContainer select').change(function() {
alert($(this).find('option:selected').text());
});