鉴于此 div:
<div id="addActor1">
<select type="select" id="ddlSelectActor1" class="selectActor">
</select><br />
<br />
<p class="newActor">
<label id="lblAddActor1FirstName" for="txtAddActor1FirstName">First Name: </label>
<input type="text" id="txtAddActor1FirstName" size="20" />
<label id="lblAddActor1LastName" for="txtAddActor1LastName">Last Name: </label>
<input type="text" id="txtAddActor1LastName" size="20" />
</p>
</div>
When a particular option in the select (which is populated in js file) is selected, I need to check if either of the inputs has anything entered in them.
我尝试了以下和类似的方法,但无法完全弄清楚:
$('#addActorsDialog select.selectActor').each(function() {
var empty = true;
// This gives me js error in console: "Uncaught Error: Syntax error, unrecognized expression: p input:nth-child(2)]"
console.log('p html: ' + $(this).parent().find('p input:nth-child(2)]').text());
if ($(this).val() !== '0' ||
($(this).val() === 'a'
// || [if textboxes are empty]
)
) { empty = false; }
//...
});
如何在此处检查任一输入是否有值?