Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Correct way to determine if query result was found

Posted on 2011-10-07
2
Medium Priority
?
174 Views
Last Modified: 2012-05-12
I am attempting to determine if a div has a class with a certain name, then do something if it does:


        if ($('div[class*="onetime"]').length > 0)
        {
            alert("one time shipping mode");
        }
   

except the alert is firing no matter what.

What is the actual correct way to perform an action based on if a div contains an attribute with a certain phrase?
0
Comment
Question by:Tom Knowlton
2 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36932311
you're using a good way : http://jsfiddle.net/racQZ/
$(document).ready(function() {
    if($('div[class*="onetime"]').length > 0)
    {
        alert("one time shipping mode");
    }
})

Open in new window

0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 36933322
thx
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

580 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