mercredi 21 août 2019

Check if JQ includes something then do something, if not do something else

I want to make if the QR do not have www. in it then go to another url. like :

if( result.code ).text().indexOf('www.') >= 0) {
$('body').append($('<a href="https://example.com/qr/code/' + result.code + '">' + result.code + '</a><br>'));
}else{
$('body').append($('<a href="https://' + result.code + '">' + result.code + '</a><br>'));
}

Im using this QR reader : https://github.com/andrastoth/webcodecamjs

Any help would be much appropriated!

Aucun commentaire:

Enregistrer un commentaire