Q:

search a string inside a element and then put it in a conditional statement

for example i have a input, anchor tags, divident or any element that a value could be possible. how to search inside a element like to see if there is a  attribute inside of it or any value as i desire and then put it in a conditional statement like if and elseif statement and check if the selector has a  inside and if there is then alert yes else alert no or in php, echo yes if there a  inside, else echo yes.
I tried this. assume i have a textarea
var isFound = $("#apostform textarea").val().search("<br>");
alert ('there is');

question: is the alert box is still be executed even if we found no  inside of the specified text area?
I need this to be done in javascript, jquery, and in php. thank you in advance.

A:

DOM objects have properties, to search all properties for particular value you can use a for..in loop:
for (var prop in element) {

  if ( element[prop] == 'some value' ) {

    // do stuff

  } else {

    // do other stuff

  }
}

or if you know the property you're after and just want to see if it has a truthy value:
if (element.property) {
  // do stuff
}

