我有以下html代码段。
<tr>
<td>Candidate: ${candidate1}</td>
<td>
<div class="radio"><label><input name="confidence_level" required="" type="radio" value="highly confident" />Highly Confident </label></div>
</td>
<td>
<div class="radio"><label><input name="confidence_level" required="" type="radio" value="moderately confident" />Moderately Confident </label></div>
</td>
<td>
<div class="radio"><label><input name="confidence_level" required="" type="radio" value="not confident" />Not Confident </label></div>
</td>
</tr>
如果变量<tr>
为空,我不想显示表格行(${candidate1}
)。
我正在Amazon Mechanical Turk创建一项调查。我可以使用JavaScript而不是jQuery。我根本不熟悉JavaScript。
请注意。我已按照此guide创建调查。如果您想了解AMT使用的平台或框架,请查看该指南。
答案 0 :(得分:1)
您可以使用Jquery解决此问题:
$('.candidate span:empty').parent().parent().hide();
<tr>
<td class="candidate">
Candidate: <span>${candidate1}</span>
</td>
<td>
<div class="radio">
<label>
<input name="confidence_level" required="" type="radio" value="highly confident" />Highly Confident
</label>
</div>
</td>
<td>
<div class="radio">
<label>
<input name="confidence_level" required="" type="radio" value="moderately confident" />Moderately Confident
</label>
</div>
</td>
<td>
<div class="radio">
<label>
<input name="confidence_level" required="" type="radio" value="not confident" />Not Confident
</label>
</div>
</td>
</tr>
答案 1 :(得分:0)
如果您的代码是jQueryTemplate
,则此代码可能有所帮助:
{{if candidate1 != ''}}
<tr>
<td>Candidate: ${candidate1}</td>
<td>
<div class="radio"><label><input name="confidence_level" required="" type="radio" value="highly confident" />Highly Confident </label></div>
</td>
<td>
<div class="radio"><label><input name="confidence_level" required="" type="radio" value="moderately confident" />Moderately Confident </label></div>
</td>
<td>
<div class="radio"><label><input name="confidence_level" required="" type="radio" value="not confident" />Not Confident </label></div>
</td>
</tr>
{{/if}}