鉴于此 HTML(片段):
<input type="text" name="sch_alert" value="foo@bar.co.uk" size="40"
maxlength="45" onchange="return valString(this.form.sch_alert, 0, 45, 'Invalid entry
for this field')" title="" id="idsch_alert"
placeholder="Your email address"><input type="text" name="sch_sms" value="44788xxxxxxx"
size="20" maxlength="14" title="" id="idsch_sms" placeholder="Your mobile number"><br>
<label class="companyform" for="idsch_all">All Campaigns?</label>
<select name="sch_all" title="Select Yes to extract/alert for replies on all
campaigns, otherwise select No and select specific campaigns below." id="idsch_all">
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
以下javascript有效:
new Opentip($('idsch_alert'), 'Email to receive reply data alert', 'Alert email', {style: 'myStyle'});
new Opentip($('idsch_sms'), 'Mobile phone number', 'Alert mobile', {style: 'myStyle'});
但这不会:
new Opentip($('idsch_all'), 'Extract all data?', 'Extract', {style: 'myStyle'});
最后给出了来自 opentip-prototype.js 的错误:
if (this.triggerElement.length > 1) {
throw new Error("You can't call Opentip on multiple elements.");
}
我猜问题是元素长度来自选项的数量,因为我可以为每个选项分配一个唯一的 ID,然后为每个选项创建一个 Opentip(尽管有定位错误,我可以通过分配不同的目标)。
我正在使用 opentip-prototype.js v2.4.6 (opentip.org)