Solved

Need built in jQuery "string endsWith" functionality

Posted on 2011-09-28
4
355 Views
Last Modified: 2012-05-12
I need to use jQuery to find if a string ends with "Error.jpg";

I use var but could use any type you suggest.

How do I do this?

Thanks.
0
Comment
Question by:newbieweb
  • 3
4 Comments
 
LVL 22

Expert Comment

by:pivar
Comment Utility
Hi,

Try

str.match(/Error.jpg$/)

/peter
0
 
LVL 22

Accepted Solution

by:
pivar earned 500 total points
Comment Utility
Oh sorry, should be

str.match(/Error\.jpg$/)
0
 
LVL 22

Expert Comment

by:pivar
Comment Utility
And to test if it ends with

if (str.match(/Error\.jpg$/) != null)
0
 

Author Closing Comment

by:newbieweb
Comment Utility
Thanks.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now