Uncaught TypeError: $(this).search is not a function
$(document).ready(function(){
$('#caption').on('keypress', function () {
var n = $(this).search('#');
if(n != "-1"){
window.alert("There's a hash");
}else{
window.alert("There's not a hash");
}
});
});
search
is a JavaScript method for a string type.
So if you want to use search
, your line var n = $(this).search('#');
should be changed to var n = $(this).val().search('#');
or var n = $(this).text().search('#');
depending on the tag of #caption
element.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments