How can i determine if first occurance (element 0) of contains text "No Errors"
if ($(xml).find('errors')[0].text() == 'No Errors')
{
do something
}
!!! edit !!!
found it...
if ($(xml).find('error').first().text() == 'No errors')
Using [0] causes JavaScript/jQuery to return the DOM node, instead of the jQuery object, you might try:
if ($(xml).find('.errors:first').text() == 'No Errors')
{
// do something
}
Or:
if ($(xml).find('.errors').eq(0).text() == 'No Errors')
{
// do something
}
Both of these if statements require that the text is, not simply contains, equal to 'No Errors'.
To test that the text contains the text 'No Errors':
if ($(xml).find('.errors').eq(0).text().toLowerCase().indexOf('no errors') > -1)
{
// do something
}
JS Fiddle demo.
References:
:first.eq().toLowerCase().indexOf().If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With