3
I don’t understand why when I look for PALAVRA
the inArray()
jQuery does not find it. But if I look for palavra
is positive when the array is PALAVRA
.
The first test I expected to be positive does not work, why? In the manual it says that the comparison of values is strict, which means in this case?
var titles = ['{EXTENSIONS}', '{dummy}'];
var title1 = "{EXTENSIONS}";
if( $.inArray( title1, titles ) ) {
$('#txt1').text('No!'); // Não entra
}
var title2 = "{extensions}";
if( $.inArray( title2, titles ) ) {
$('#txt2').text('Yes!'); // Entra
}
var title3 = "{dummy}";
if( $.inArray( title3, titles ) ) {
$('#txt3').text('Yes!');
}
PS: The
in_array
of PHP is case sensitive and works as expected. Will it be a pro Nannannannannan, Batman?– brasofilo
As a joke, I could switch to Mootools :) and use the contains(), where the name is more according to what the code does :)
– Sergio
The
~
in its solution is master stroke, it was worth asking without having read the manual carefully :) In fact, it is a plugin pro Stackedit.io, has to be jQ, but it was worth the tip!– brasofilo