Possible Duplicate:
jQuery find and replace string
This is my html:
<div class="dt_lft">There is an error</div>
I need to find whether the div has the text error and replace that text with success using class name. How to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
http://jsfiddle.net/ztCcB/1/
$("div.dt_lft:contains('error')")returns all divs with classdt_lftcontaining worderror, you can read more about jQuery contains selector. With jQuery.text()you can write function like:Elsewhere, if your object contains word
errormany times, you can do:In case you do not want to use RegEx.