Pergunta

I'm getting content from external host through PHP file_get_element and jQuery .load() and inside this content there is a div with some text like this:

"Department of Orthopaedics, Vienna General Hospital and the University of Vienna, Austria." or "Department of Neurosurgery, Donauspital SMZ-Ost, Vienna, Austria." or "Department of Traumatology, University of Innsbruck, Anichstrasse 35, A-6020 Innsbruck, Austria. hacklwol@hotmail.com" or "Orthopädisches Spital Speising, Vienna, Austria. j.krugluger@innonet.at"

For every .load I make I get a diferent text, and what i need to do is save in my database the departments, but the problem is the different languages (Orthopedic, Orthopädisches, Orthopaedics, etc).

In all the cases I can find "Ortho" or "Neuro", or "Trauma", so I've tried something like this:

    if($(".afflist:contains('Ortho')")){ ortho = 1; }
    if($(".afflist:contains('Neuro')")){ neuro = 1; }

Please, someone help me.

Foi útil?

Solução

jQuery(selector) will return a jQuery Object which will be truthy always, you need to check whether the number of elements returned by the selector is greater than 0 like

if ($(".afflist:contains('Ortho')").length) {
    ortho = 1;
}
if ($(".afflist:contains('Neuro')").length) {
    neuro = 1;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top