我有一个自动生成的表格,来自提供商的js,我很遗憾无法改变......
但是我想知道是否只有解决方案允许我选择所有以相同字符串开头的id,如:easi_fielddiv_LastName,easi_fielddiv_FirstName,easi_fielddiv_Email等...因为想法是选择所有这些并将它们应用于我的css会更加有效。
这是表单代码:
<div id="easiformarea">
<form name="easiform" id="easiform" class="easiform">
<div id="easi_fielddiv_Salutation">
<span id="easi_labelspan_Salutation"><label id="easi_fieldlabel_Salutation">Civilité</label></span>
<span id="easi_fieldspan_Salutation">
<select id="fld_Salutation" name="fld_Salutation" label="Civilité" mandatory="true">
<option value="" label=""></option>
<option value="Mme" label="Madame">Madame</option>
<option value="Mlle." label="Mademoiselle">Mademoiselle</option>
<option value="Mr" label="Monsieur">Monsieur</option>
</select>
</span>
<span id="easi_fielmandatoryspan_Salutation" class="mandatory"> * </span>
</div>
<div id="easi_fielddiv_LastName"><span id="easi_labelspan_LastName"><label id="easi_fieldlabel_LastName">Nom</label></span><span id="easi_fieldspan_LastName"><input id="fld_LastName" type="text" name="fld_LastName" label="Nom" mandatory="true"></span><span id="easi_fielmandatoryspan_LastName" class="mandatory"> * </span></div>
<div id="easi_fielddiv_FirstName"><span id="easi_labelspan_FirstName"><label id="easi_fieldlabel_FirstName">Prénom</label></span><span id="easi_fieldspan_FirstName"><input id="fld_FirstName" type="text" name="fld_FirstName" label="Prénom" mandatory="true"></span><span id="easi_fielmandatoryspan_FirstName" class="mandatory"> * </span></div>
<div id="easi_fielddiv_Email"><span id="easi_labelspan_Email"><label id="easi_fieldlabel_Email">Email</label></span><span id="easi_fieldspan_Email"><input id="fld_Email" type="text" name="fld_Email" label="Email" mandatory="true"></span><span id="easi_fielmandatoryspan_Email" class="mandatory"> * </span></div>
<div id="easi_fielddiv_OfficePhoneNumber"><span id="easi_labelspan_OfficePhoneNumber"><label id="easi_fieldlabel_OfficePhoneNumber">Téléphone</label></span><span id="easi_fieldspan_OfficePhoneNumber"><input id="fld_OfficePhoneNumber" type="text" name="fld_OfficePhoneNumber" label="Téléphone" mandatory="false"></span></div>
<div id="easi_fielddiv_CS_Booking"><span id="easi_labelspan_CS_Booking"><label id="easi_fieldlabel_CS_Booking">Booking</label></span><span id="easi_fieldspan_CS_Booking"><input id="fld_CS_Booking" type="text" name="fld_CS_Booking" label="Booking" mandatory="false"></span></div>
<div id="easi_fielddiv_CS_Subject">
<span id="easi_labelspan_CS_Subject"><label id="easi_fieldlabel_CS_Subject">Sujet</label></span>
<span id="easi_fieldspan_CS_Subject">
<select id="fld_CS_Subject" name="fld_CS_Subject" label="Sujet" mandatory="true">
<option value="" label=""></option>
<option value="1" label="Je veux annuler mon vol">Je veux annuler mon vol</option>
</select>
</span>
<span id="easi_fielmandatoryspan_CS_Subject" class="mandatory"> * </span>
</div>
<div id="easi_fielddiv_CS_SubSubject">
<span id="easi_labelspan_CS_SubSubject"><label id="easi_fieldlabel_CS_SubSubject">Sous-sujet</label></span>
<span id="easi_fieldspan_CS_SubSubject">
<select id="fld_CS_SubSubject" name="fld_CS_SubSubject" label="Sous-sujet" mandatory="true">
<option value="" label=""></option>
</select>
</span>
<span id="easi_fielmandatoryspan_CS_SubSubject" class="mandatory"> * </span>
</div>
<div id="easi_fielddiv_Description"><span id="easi_labelspan_Description"><label id="easi_fieldlabel_Description">Description</label></span><span id="easi_fieldspan_Description"><textarea id="fld_Description" name="fld_Description" label="Description" mandatory="false"></textarea></span></div>
<div id="easi_fielddiv_AttachedFiles">
<span id="easi_labelspan_AttachedFiles"><label id="easi_fieldlabel_AttachedFiles">Pièces jointes</label></span>
<span id="easi_fieldspan_AttachedFiles">
<div id="fld_AttachedFilesarea"> <input id="fld_AttachedFiles" type="file" name="fld_AttachedFiles" label="Pièces jointes" mandatory="false" multiple=""></div>
</span>
</div>
<span class="easiformmessages" id="easiformmessages"></span>
</form>
<div class="mandatoryfieldmention" id="mandatoryfieldmention">* champs obligatoires</div>
<div class="additionnalInformation" id="additionnalInformation">Un numéro de dossier renseigné est une demande traitée plus rapidement!</div>
<button id="validatebutton" class="validatebutton" onclick="myformbuilder.valideasiform();">Envoyer</button>
</div>
我尝试在输入上按标签名称选择元素,然后让parent().parent()
达到我感兴趣的ID,但它似乎不起作用...
所以任何帮助都表示赞赏!!!谢谢:))
答案 0 :(得分:0)
你可以试试这个(需要jQuery)
$('*[id^="easi_fielddiv"]');
这将选择以&#39; easy_fielddiv&#39;
开头(^)的所有元素(*)