I’m trying to find whether there is some character in my string in JS
Like that :
$('.upld_btn').bind("click", function () {
changeApiFormat($('#embbed').val());
});
if ($('#embbed.contains("?vid=")')) {
....
....
}
I’ve got an error in my google chrome console :
Object XXXX has no method 'contains'
How come?!
I assume
#embbedis an input value of some kind (because of your call to.val()above). So, you would want to pull its value here, as well, and useindexOf(-1indicates not found):Here is a jsFiddle illustrating proof-of-concept. Enter “Hi”, or “aHia”, or anything like that (case-sensitive) into the box and click the link, and you will get a success popup. Otherwise you will get a failure popup.
Code used: