Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  174] [ 6]  / answers: 1 / hits: 30217  / 12 Years ago, fri, april 27, 2012, 12:00:00

I have a variable: $form.attr('action') that contains one of the following:



action=/Administration/Contents/JsonCreate
action=/Administration/Contents/JsonEdit
action=/Administration/Contents/JsonDelete


How can I with an if () statement check to see if it contains the word JsonEdit ?


More From » javascript

 Answers
20

Use indexOf():



var str = $form.attr('action');

if(str.indexOf(JsonEdit)>=0){
//do something you want
}

[#85936] Thursday, April 26, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dannyc

Total Points: 517
Total Questions: 106
Total Answers: 116

Location: Netherlands
Member since Mon, Jun 7, 2021
3 Years ago
;