Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

find id attribute that has both phrases inside it

Posted on 2013-02-04
4
Medium Priority
?
245 Views
Last Modified: 2013-02-04
<span id="ctl09_gvRepair_ctl03_lblAmt1" style="border: 1px solid green;">1700.00</span>

using jQuery I want to find all spans where the id contains BOTH:

"gvRepair"

and

"lblAmt"

within the same id attribute.


How can I do this?

//pseudocode...
 $('span[id*="lblAmt"]  AND ALSO [id*="gvRepair"] ').each(function () {
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 38853253
sing : http://api.jquery.com/filter/

$('span').filter(function() { return ( $(this).attr("id").indexOf("lblAmt")>=0 ) && ( $(this).attr("id").indexOf("gvRepair")>=0 ); }).each(function () {

Open in new window

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853334
Yep, it worked.


For my own notes:

   $('span').filter(function() { return ( $(this).attr("id").indexOf("lblAmt")>=0 ) && ( $(this).attr("id").indexOf("gvRepair")>=0 ); }).each(function () {
            subtotRepair += parseFloat($(this).text());
        });

        $('span').filter(function () { return ($(this).attr("id").indexOf("lblAmt") >= 0) && ($(this).attr("id").indexOf("gvRecommended") >= 0); }).each(function () {
            subtotRecommended += parseFloat($(this).text());
        });


        alert(subtotRepair);
        alert(subtotRecommended);

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 38853342
if you add a the same class to all your label you should be able to use :

$(".myLabelClass").each(function() {
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853345

if you add a the same class to all your label you should be able to use :

$(".myLabelClass").each(function() {


Thank you!  I'd forgotten about that!
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

636 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