1

how to loop through a set of elements with a data attribute value using jquery? I tried this... alert(variableName); // works

    $("SectionATable tr [data-testlog='"+variableName+"']").each(function()
    {
                alert("sectionA log");
    });

No error shows up in firebug....

2
  • data-testlog is assigned to TR or to the children TD elements? and also are you missing an # ? Commented Apr 15, 2013 at 15:41
  • perhaps you mean #SectionATable as SectionATable wouldn't be a tagname. also, when you are working with selectors it helps to show the html that it is using. Commented Apr 15, 2013 at 15:41

2 Answers 2

2

you had a few small syntax errors, try this:

$("#SectionATable tr [data-testlog="+variableName+"]").each(function(){
    alert("sectionA log");
});
Sign up to request clarification or add additional context in comments.

Comments

1

Attribute Equals Selector [name="value"]

here are selecotrs http://api.jquery.com/category/selectors/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.