私のHTML:
<form>
<input type="text" name="url" maxlength="10" />
</form>
私のJS:
$(document).ready(function(){
var inputUrl = $('input[name=url]');
inputUrl.change(function() {
alert(inputUrl);
if ($(inputUrl).contains('watch'))
{
alert ('Contains watch: yes');
}
else
{
alert ('Contains watch: no');
}
});
});
Chrome コンソールの表示:
Uncaught TypeError: Object [object Object] has no method 'contains'
次の正しい構文は何ですか:
if ($(inputUrl).contains('watch'))